Skip to content

Commit 42cf14b

Browse files
Steinar H. Gundersonchromium-wpt-export-bot
authored andcommitted
Fix token pasting with empty fallbacks.
When deciding whether we'd need to insert a dummy comment between two tokens in CSS token pasting, an empty fallback could confuse the logic, in that we thought we inserted an EOF token. Fix by having an early return from empty fallbacks; they shouldn't affect the output in any reasonable way. Fixed: 426549962 Change-Id: I0d1f330dd5a507c660395e0d7089873fa5382d12 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6650923 Auto-Submit: Steinar H Gunderson <[email protected]> Commit-Queue: Anders Hartvoll Ruud <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1477216}
1 parent 23efff3 commit 42cf14b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

css/css-syntax/serialize-consecutive-tokens.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,15 @@
123123
testComments("var(--t1)b", "\"a/* unfinished \"", "\"a/* unfinished \"b");
124124
testComments("var(--t1)b", "'a \" '/* comment */", "'a \" 'b");
125125

126+
test(()=>{
127+
const b = document.body;
128+
b.style.setProperty("--t1", "a");
129+
b.style.setProperty("--t2", "b");
130+
b.style.setProperty("--result", "var(--t1)var(--does-not-exist,)var(--t2)");
131+
const result = getComputedStyle(b).getPropertyValue("--result");
132+
assert_equals(result[0], "a", `Result must start with a`);
133+
assert_equals(result[result.length - 1], "b", `Result must end with b`);
134+
assert_not_equals(result, "ab", `Result must have a comment between a and b`);
135+
}, 'Empty fallback between tokens must not disturb comment insertion');
136+
126137
</script>

0 commit comments

Comments
 (0)