Skip to content

Commit 3ff2fd4

Browse files
test: read empty style and script as dropped, and skip them before a joined style
1 parent e56609f commit 3ff2fd4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎test/helpers/syntaxEquivalence.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ const installHelpers = (generics) => {
655655
// Elements whose empty, attribute-less form renders nothing and is read by
656656
// nothing: no box, marker, margin, widget or generated text of their own.
657657
const RENDERS_NOTHING_EMPTY = new Set(
658-
"a abbr address article aside b bdi bdo cite code data del dfn div em footer header i ins kbd label main mark nav s samp section small span strong sub sup time title u var base link meta".split(
658+
"a abbr address article aside b bdi bdo cite code data del dfn div em footer header i ins kbd label main mark nav s samp script section small span strong style sub sup time title u var base link meta".split(
659659
" "
660660
)
661661
);
@@ -809,13 +809,17 @@ const installHelpers = (generics) => {
809809
if (element.namespaceURI !== NS_HTML || element.localName !== "style") {
810810
return false;
811811
}
812-
// Only whitespace and comments may stand between two sheets a merge joins.
812+
// Only whitespace, comments and what prints nothing stand between two
813+
// sheets a merge joins.
813814
let previous = element.previousSibling;
814815
while (
815816
previous !== null &&
816817
(previous.nodeType === Node.COMMENT_NODE ||
817818
(previous.nodeType === Node.TEXT_NODE &&
818-
/^[\t\n\f\r ]*$/.test(previous.nodeValue || "")))
819+
/^[\t\n\f\r ]*$/.test(previous.nodeValue || "")) ||
820+
(previous.nodeType === Node.ELEMENT_NODE &&
821+
relaxedSet.has("empty-elements") &&
822+
isEmptyElement(/** @type {Element} */ (previous))))
819823
) {
820824
previous = previous.previousSibling;
821825
}

0 commit comments

Comments
 (0)