You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When markup appears after </body> or </html>, the document's original <body> is lost.
There is a bug in \Amp\AmpWP\Dom\Document::normalize_document_structure() in particular with the pattern in \Amp\AmpWP\Dom\Document::HTML_STRUCTURE_BODY_END_TAG as used here:
This is causing new <body> to be added to the page which is blowing away the existing one.
Expected Behaviour
The original <body> with all of its valid attributes should not be removed during normalization when there is markup or HTML comments appearing after </body> or </html>. Any markup appearing after </body> should get moved inside during normalization, although beware of moving HTML comment nodes as this may cause problems with validation. This came up before previously in #4104.
Steps to reproduce
Modify the footer.php of Twenty Twenty to end with:
</body></html><!-- a comment! -->
or
</body><!-- a comment! --></html>
When then look at an AMP page in Standard/Transitional mode. Notice that the body element of the page is now just:
Bug Description
When markup appears after
</body>
or</html>
, the document's original<body>
is lost.There is a bug in
\Amp\AmpWP\Dom\Document::normalize_document_structure()
in particular with the pattern in\Amp\AmpWP\Dom\Document::HTML_STRUCTURE_BODY_END_TAG
as used here:amp-wp/src/Dom/Document.php
Lines 492 to 497 in 2026afc
This is causing new
<body>
to be added to the page which is blowing away the existing one.Expected Behaviour
The original
<body>
with all of its valid attributes should not be removed during normalization when there is markup or HTML comments appearing after</body>
or</html>
. Any markup appearing after</body>
should get moved inside during normalization, although beware of moving HTML comment nodes as this may cause problems with validation. This came up before previously in #4104.Steps to reproduce
Modify the
footer.php
of Twenty Twenty to end with:or
When then look at an AMP page in Standard/Transitional mode. Notice that the
body
element of the page is now just:Whereas it should be:
Screenshots
Additional context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: