Skip to content

Commit

Permalink
Make color-scheme meta affect all normal schemes
Browse files Browse the repository at this point in the history
The HTML specification changed to use the meta color-scheme as a page's
supported color schemes instead of presentation style for the root
element. This means the color-scheme meta no longer affects the
computed for an initial value root element, but still affects the used
color-scheme the same way as before.

There is one used value change, and that is when resetting the
color-scheme to "normal" down the tree, which now follows the meta
element instead of resolving to a "light" color-scheme.

We now align with Gecko and Safari.

See the whatwg issue[1] for a discussion.

[1] whatwg/html#7213

Bug: 1260617
Change-Id: Ic72a2dead75257650f8d99cc5f30f13b7005ea41
  • Loading branch information
lilles authored and chromium-wpt-export-bot committed Mar 31, 2022
1 parent d11bdd4 commit ae24b39
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<title>Change color-scheme meta tag affecting normal descendant</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta id="meta" name="color-scheme" content="dark">
<div style="color-scheme: dark; color: CanvasText" id="dark">
<div style="color-scheme: normal; color: CanvasText" id="normal"></div>
</div>
<script>
test(() => {
assert_equals(getComputedStyle(dark).color, getComputedStyle(normal).color);
}, "Normal initially dark");

meta.content = "light";

test(() => {
assert_not_equals(getComputedStyle(dark).color, getComputedStyle(normal).color);
}, "Normal should change to light from page color schemes");
</script>

0 comments on commit ae24b39

Please sign in to comment.