Skip to content

Commit

Permalink
Make :has() unforgiving
Browse files Browse the repository at this point in the history
Apply the issue resolution of making :has() unforgiving:
w3c/csswg-drafts#7676 (comment)

Bug: 1399744
Change-Id: Ibb499e251ecce7ba22bd454ea94b2c8c8b1d8afb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4090967
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Byungwoo Lee <blee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1081452}
  • Loading branch information
byung-woo authored and BruceDai committed Dec 13, 2022
1 parent 1db570c commit b423418
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<title>CSS Conditional Test: @supports selector() detecting invalid in forgiving argument.</title>
<title>CSS Conditional Test: @supports selector() detecting invalid in logical combinations.</title>
<link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com">
<style>
div {
Expand All @@ -15,3 +15,5 @@
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!doctype html>
<title>CSS Conditional Test: @supports selector() detecting invalid in forgiving argument.</title>
<title>CSS Conditional Test: @supports selector() detecting invalid in logical combinations.</title>
<link rel="author" title="Byungwoo Lee" href="mailto:blee@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-conditional/#at-supports">
<link rel="match" href="at-supports-selector-detecting-invalid-in-forgiving-argument-ref.html">
<link rel="match" href="at-supports-selector-detecting-invalid-in-logical-combinations-ref.html">
<style>
div.invalid {
background-color: green;
Expand All @@ -23,6 +23,9 @@
@supports selector(:has(.a)) {
div.has.valid { background: green };
}
@supports selector(:not(.a)) {
div.not.valid { background: green };
}
@supports selector(:is(:foo, .a)) {
div.is.invalid { background: red };
}
Expand All @@ -32,11 +35,16 @@
@supports selector(:has(:foo, .a)) {
div.has.invalid { background: red };
}
@supports selector(:not(:foo, .a)) {
div.not.invalid { background: red };
}
</style>
<p>Test passes if there is a <strong>filled green square</strong> and <strong>no red</strong>.</p>
<div class="is valid"></div>
<div class="where valid"></div>
<div class="has valid"></div>
<div class="not valid"></div>
<div class="is invalid"></div>
<div class="where invalid"></div>
<div class="has invalid"></div>
<div class="not invalid"></div>
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<!doctype html>
<meta charset="utf-8">
<title>CSS.supports() detecting invalid in forgiving argument</title>
<title>CSS.supports() detecting invalid in logical combinations</title>
<link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(CSS.supports("selector(:has(:foo))"), false);
assert_equals(CSS.supports("selector(:has(.a, :foo))"), false);
assert_equals(CSS.supports("selector(:has(:foo, .a))"), false);
assert_equals(CSS.supports("selector(:not(:foo))"), false);
assert_equals(CSS.supports("selector(:not(.a, :foo))"), false);
assert_equals(CSS.supports("selector(:not(:foo, .a))"), false);
}, "Invalid selector can be detected with CSS.supports()");

test(function() {
assert_equals(CSS.supports("selector(:is(:foo))"), false);
assert_equals(CSS.supports("selector(:is(.a, :foo))"), false);
Expand All @@ -14,9 +23,6 @@
assert_equals(CSS.supports("selector(:where(.a, :foo))"), false);
assert_equals(CSS.supports("selector(:where(:foo, .a))"), false);
assert_equals(CSS.supports("selector(:where(:is(:foo, a), .b))"), false);
assert_equals(CSS.supports("selector(:has(:foo))"), false);
assert_equals(CSS.supports("selector(:has(.a, :foo))"), false);
assert_equals(CSS.supports("selector(:has(:foo, .a))"), false);
assert_equals(CSS.supports("selector(:has(:where(:foo, a), .b))"), false);
}, "Invalid selector can be detected with CSS.supports() even if it is dropped by forgiving parsing");

Expand Down

0 comments on commit b423418

Please sign in to comment.