Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[:has() pseudo-class] Support invalidation for :defined pseudo class
https://bugs.webkit.org/show_bug.cgi?id=257385 rdar://109896689 Reviewed by Ryosuke Niwa. Use PseudoClassChangeInvalidation instead of manually invalidating the subtree, which does not take in account :has(). * LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/defined-in-has-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/defined-in-has.html: Added. * Source/WebCore/dom/Element.cpp: (WebCore::Node::setCustomElementState): (WebCore::Element::setIsDefinedCustomElement): Canonical link: https://commits.webkit.org/264602@main
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ts/imported/w3c/web-platform-tests/css/selectors/invalidation/defined-in-has-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Test :defined pseudo-class invalidation with :has() | ||
|
||
PASS Test :has() invalidation with :defined pseudo-class | ||
|
37 changes: 37 additions & 0 deletions
37
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/defined-in-has.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<title>:has() invalidation with :defined pseudo-class</title> | ||
<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m"> | ||
<link rel="help" href="https://drafts.csswg.org/selectors/#relational"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined"> | ||
<style> | ||
#subject { | ||
background-color: red; | ||
width: 100px; | ||
height: 100px; | ||
} | ||
#subject:has(:defined) { | ||
background-color: green; | ||
} | ||
</style> | ||
<body> | ||
Test :defined pseudo-class invalidation with :has() | ||
<div id="subject"> | ||
<my-element></my-element> | ||
</div> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
const GREEN = "rgb(0, 128, 0)"; | ||
const RED = "rgb(255, 0, 0)"; | ||
|
||
function assert_matches_defined(defined) { | ||
assert_equals(getComputedStyle(subject).backgroundColor, defined ? GREEN : RED); | ||
} | ||
|
||
test(() => { | ||
assert_matches_defined(false); | ||
customElements.define("my-element", class MyElement extends HTMLElement { }); | ||
assert_matches_defined(true); | ||
}, "Test :has() invalidation with :defined pseudo-class"); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters