Skip to content

data-amp-no-unwrap effectiveness restricted to <body> element, disregarded in <head> #7234

Open
@anrghg

Description

@anrghg

Bug Description

<noscript> elements with the data-amp-no-unwrap property in the <head> are unwrapped regardless.

Expected Behaviour

<noscript data-amp-no-unwrap><style> /* This CSS applies only if JS is off. */ </style></noscript>

Screenshots

In the body, there is this test code:

<noscript data-amp-no-unwrap>JavaScript is off.</noscript><br />
<noscript>This page is served as AMP if this message shows up while JavaScript is on.</noscript>

On a page served as AMP: https://anrghg.sunsite.fr/test-amp-compat/features/helpers/#127-amp-compatibility
On a non-AMP page: https://anrghg.sunsite.fr/publishing-helper/features/helpers/#127-amp-compatibility
(before the next heading).

In the head, there is this selector on both pages:

.anrghg-display-toggle:not(:checked)+.anrghg-tocontents .anrghg-contents-list .anrghg-contents-heading:target

On the non-AMP page, it is wrapped into <noscript data-amp-no-unwrap>.
On the AMP page, it survives tree-shaking and is in the valid CSS because it is unwrapped.

The adverse effect on the AMP is that a TOC item shows up below the TOC label after clicking a heading number, then reloading the page, while JS is on.

PHP Version

8.1

Plugin Version

2.3.0

AMP plugin template mode

Standard

WordPress Version

6.0.1

Site Health

https://anrghg.sunsite.fr/test-amp-compat/wp-content/uploads/sites/3/2022/08/site-health_2022-08-30T22500200.txt

Gutenberg Version

OS(s) Affected

Linux

Browser(s) Affected

Brave

Device(s) Affected

desktop

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingP2Low priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions