Skip to content

Commit

Permalink
Fix cssom subtest for nesting.
Browse files Browse the repository at this point in the history
As per w3c/csswg-drafts#7961 bare tag
selectors and so are fine now.

Differential Revision: https://phabricator.services.mozilla.com/D181799

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1839946
gecko-commit: b271d6ad5492b424ca52dd82097b08f90cd07be5
gecko-reviewers: boris
  • Loading branch information
emilio authored and moz-wptsync-bot committed Jun 28, 2023
1 parent 1b03e56 commit 3d67ca9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions css/css-nesting/cssom.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,19 @@
}`, 'color is changed, new rule is ignored');
});

// We cannot insert anything starting with an tag, as that would cause
// the serialized rule not to parse back. Compounds starting with a tag
// that are _not_ the first compound in a complex selector are OK, though,
// as are complex selectors that are not the first in the list.
test(() => {
document.getElementById('ss').innerHTML = sampleSheetText;
let [ss] = document.styleSheets;
ss.cssRules[0].cssRules[0].selectorText = 'div.b .c &'; // Ignored.
ss.cssRules[0].cssRules[0].selectorText = 'div.b .c &'; // Allowed
ss.cssRules[0].cssRules[1].selectorText = '.c div.b &, div &'; // Allowed.
assert_throws_dom('SyntaxError', () => { ss.cssRules[0].insertRule('div & {}'); });
ss.cssRules[0].insertRule('div & {}'); // Allowed.
assert_equals(ss.cssRules[0].cssText,
`.a {
color: red;
& .b { color: green; }
div & { }
div.b .c & { color: green; }
.c div.b &, div & { color: blue; }
}`, 'one rule is kept unchanged, the other is changed');
}`, 'selectorText and insertRule');
});

// Rules that are dropped in forgiving parsing but that contain &,
Expand Down

0 comments on commit 3d67ca9

Please sign in to comment.