Skip to content

Commit fc504f7

Browse files
committed
Bug 1872005 [wpt PR 43800] - Implement :state(foo) alongside :--foo, a=testonly
Automatic update from web-platform-tests Implement :state(foo) alongside :--foo This patch implements :state(foo) alongsite :--foo so that we can have both supported on stable at the same time and then deprecate/remove :--foo. This patch does not enable :state(foo) by default. I will do that after implementing deprecation for :--foo. Due to pushback from webkit, the syntax for this feature was discussed again in the CSSWG, and a resolution was made to go back from :--foo to :state(foo): w3c/csswg-drafts#4805 (comment) This was discussed in an I2S where we decided to only deprecate :--foo if WebKit ships :--foo, which has now happened. https://groups.google.com/a/chromium.org/g/blink-dev/c/JvpHoUfhJYE Fixed: 1508033 Bug: 1514397 Change-Id: I497fd5acc05ba033e8e72c429568099c89d5d639 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5153145 Reviewed-by: Mason Freed <masonfchromium.org> Auto-Submit: Joey Arhar <jarharchromium.org> Commit-Queue: Joey Arhar <jarharchromium.org> Cr-Commit-Position: refs/heads/main{#1254746} -- wpt-commits: 9fd7672ceccd3cfec2ecc89647963acf5ae3c372 wpt-pr: 43800 UltraBlame original commit: 9ba5dbb2106671ac2cb5dff896340046d96e0e1c
1 parent 9ecaf5f commit fc504f7

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

testing/web-platform/tests/custom-elements/state/tentative/ElementInternals-states.html

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
test(() => {
2828
let i = (new TestElement()).internals;
2929
assert_throws_js(TypeError, () => { i.states.supports('foo'); });
30+
i.states.add(''); // should not throw.
31+
i.states.add('--a\tb'); // should not throw.
3032
}, 'CustomStateSet behavior of ElementInternals.states: Exceptions');
3133

3234
test(() => {

testing/web-platform/tests/custom-elements/state/tentative/state-pseudo-class.html

+16-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#state-and-part:state(outerFoo)::part(inner) {
1212
opacity: 0.25;
1313
}
14-
:state(--\)escaped\ state) {}
14+
:state( \(escaped\ state ) {}
1515
</style>
1616
<body>
1717
<script>
@@ -60,22 +60,29 @@
6060
document.querySelector(':state(--16px)');
6161
}, ':state() parsing passes');
6262

63+
test(() => {
64+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state'); });
65+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state('); });
66+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state()'); });
67+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state(=)'); });
68+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state(name=value)'); });
69+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state( foo bar)'); });
70+
assert_throws_dom('SyntaxError', () => { document.querySelector(':state(16px)'); });
71+
}, ':state() parsing failures');
72+
6373
test(() => {
6474
assert_throws_dom('SyntaxError', () => { document.querySelector(':--('); });
6575
assert_throws_dom('SyntaxError', () => { document.querySelector(':--()'); });
66-
assert_throws_dom('SyntaxError', () => { document.querySelector(':state()'); });
6776
assert_throws_dom('SyntaxError', () => { document.querySelector(':--)'); });
6877
assert_throws_dom('SyntaxError', () => { document.querySelector(':--='); });
6978
assert_throws_dom('SyntaxError', () => { document.querySelector(':--name=value'); });
70-
assert_throws_dom('SyntaxError', () => { document.querySelector(':state(--name=value'); });
71-
assert_throws_dom('SyntaxError', () => { document.querySelector(':state(--name=value)'); });
72-
}, ':state() parsing failures');
79+
}, 'deprecated :--state parsing failures');
7380

7481
test(() => {
7582
assert_equals(document.styleSheets[0].cssRules[1].cssText,
7683
'#state-and-part::part(inner):state(innerFoo) { opacity: 0.5; }');
7784
assert_equals(document.styleSheets[0].cssRules[3].selectorText,
78-
':state(--\\)escaped\\ state)');
85+
':state(\\(escaped\\ state)');
7986
}, ':state(foo) serialization');
8087

8188
test(() => {
@@ -112,13 +119,13 @@
112119
let inner = outer.innerElement;
113120
let innerStates = inner.i.states;
114121

115-
innerStates.add(':state(innerFoo)');
122+
innerStates.add('innerFoo');
116123
assert_equals(getComputedStyle(inner).opacity, '0.5',
117-
'::part() followed by :state(innerFoo)');
124+
'::part() followed by :state()');
118125
innerStates.delete('innerFoo');
119126
innerStates.add('innerfoo');
120127
assert_equals(getComputedStyle(inner).opacity, '0',
121-
':state(foo) matching should be case-sensitive');
128+
':state() matching should be case-sensitive');
122129
innerStates.delete('innerfoo');
123130

124131
outer.i.states.add('outerFoo');

0 commit comments

Comments
 (0)