Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mdubet authored Aug 16, 2023
1 parent bce1025 commit 31d3218
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions css/css-nesting/nest-containing-forgiving-ref.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<body>
<p>Tests pass if <strong>block is green</strong></p>
<div class="test"></div>
<div class="test"></div>
</body>
7 changes: 7 additions & 0 deletions css/css-nesting/nest-containing-forgiving.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
}
}

.does-not-exist {
:is(.test-2, :unknown(div,&)) {
background-color: green;
}
}

body * + * {
margin-top: 8px;
}
</style>
<body>
<p>Tests pass if <strong>block is green</strong></p>
<div class="test test-1"></div>
<div class="test test-2"></div>
</body>
8 changes: 4 additions & 4 deletions css/css-scoping/slotted-parsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
test_valid_selector("::slotted(:not(.a))");

test_valid_selector("::slotted(*):is()");
test_valid_selector("::slotted(*):is(:hover)", "::slotted(*):is()");
test_valid_selector("::slotted(*):is(#id)", "::slotted(*):is()");
test_valid_selector("::slotted(*):is(:hover)");
test_valid_selector("::slotted(*):is(#id)");

test_valid_selector("::slotted(*):where()");
test_valid_selector("::slotted(*):where(:hover)", "::slotted(*):where()");
test_valid_selector("::slotted(*):where(#id)", "::slotted(*):where()");
test_valid_selector("::slotted(*):where(:hover)");
test_valid_selector("::slotted(*):where(#id)");

// Allow tree-abiding pseudo elements after ::slotted
test_valid_selector("::slotted(*)::before");
Expand Down
16 changes: 5 additions & 11 deletions css/selectors/is-where-error-recovery.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@
"random-selector",
"Should've parsed",
);
assert_not_equals(
rule.selectorText,
invalidSelector,
"Should not be considered valid and parsed as-is",
);
let emptyList = `:${pseudo}()`;
assert_equals(
rule.selectorText,
emptyList,
"Should be serialized as an empty selector-list",
invalidSelector,
"Should be parsed as-is (but not be considered valid)",
);
assert_equals(document.querySelector(emptyList), null, "Should never match, but should parse");
assert_equals(document.querySelector(rule.selectorText), null, "Should never match, but should parse");
for (let mixedList of [
`:${pseudo}(:total-nonsense, #test-div)`,
`:${pseudo}(:total-nonsense and-more-stuff, #test-div)`,
Expand All @@ -43,8 +37,8 @@
rule.selectorText = mixedList;
assert_equals(
rule.selectorText,
`:${pseudo}(#test-div)`,
`${mixedList}: Should ignore invalid selectors`,
mixedList,
`${mixedList}: Should parse invalid selectors`,
);
let testDiv = document.getElementById("test-div");
assert_equals(document.querySelector(mixedList), testDiv, "Should correctly match");
Expand Down
7 changes: 4 additions & 3 deletions css/selectors/is-where-parsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</style>
<script>
let rule = document.getElementById("test-sheet").sheet.cssRules[0];
function assert_valid(expected_valid, pattern, expected_pattern, description) {
function assert_valid(expected_parseable, pattern, expected_pattern, description) {
test(function() {
for (let pseudo of ["is", "where"]) {
let selector = pattern.replace("{}", ":" + pseudo);
Expand All @@ -19,7 +19,7 @@
expected_selector = expected_pattern.replace("{}", ":" + pseudo);
rule.selectorText = "random-selector";
rule.selectorText = selector;
(expected_valid ? assert_equals : assert_not_equals)(
(expected_parseable ? assert_equals : assert_not_equals)(
rule.selectorText,
expected_selector,
`${description}: ${selector}`
Expand All @@ -42,7 +42,8 @@
assert_valid(true, "{}(:hover, :active)", null, "Pseudo-classes inside");
assert_valid(true, "{}(div):hover", null, "Pseudo-classes after");
assert_valid(true, "{}(div)::before", null, "Pseudo-elements after");
assert_valid(false, "{}(::before)", null, "Pseudo-elements inside");
// Should ask clarification from CSSWG
assert_valid(true, "{}(::before)", null, "Pseudo-elements inside");

assert_valid(true, "{}(div) + bar", null, "Combinators after");
assert_valid(true, "::part(foo):is(:hover)", null, "After part with simple pseudo-class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_selector('.a:has(.b:has(.c))');
test_valid_selector('.a:has(:is(.b:has(.c)))', '.a:has(:is())');
test_valid_selector('.a:has(:is(.b:has(.c), .d))', '.a:has(:is(.d))');
test_valid_selector('.a:has(:is(.b:has(.c)))');
test_valid_selector('.a:has(:is(.b:has(.c), .d))');
</script>
2 changes: 1 addition & 1 deletion css/selectors/parsing/parse-has.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
test_invalid_selector(':has()');
test_invalid_selector(':has(123)');
test_invalid_selector(':has(.a, 123)');
test_valid_selector(':has(:is(.a, 123))', ':has(:is(.a))');
test_valid_selector(':has(:is(.a, 123))');
</script>

0 comments on commit 31d3218

Please sign in to comment.