Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight pseudos use the forced-color status of their originating element #34223

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions forced-colors-mode/forced-colors-mode-53-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Forced colors mode - Highlight pseudos use the originating element's forced colors state</title>
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#forced-color-adjust-prop">
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
<style>
span.forcedColors {
background-color: Highlight;
color: HighlightText;
text-decoration: underline;
text-decoration-color: CanvasText;
forced-color-adjust: none;
}

span.noForcedColors {
background-color: yellow;
color: blue;
text-decoration: underline;
text-decoration-color: orange;
forced-color-adjust: none;
}
</style>
<body>
<div><span class="forcedColors">This content doesn't have forced-color-adjust set at all</span></div>
<div><span class="noForcedColors">This content has forced-color-adjust:none on the originating element only</span></div>
<div><span class="forcedColors">This content has forced-color-adjust:none on the ::highlight pseudo only</span></div>
<div><span class="noForcedColors">This content has forced-color-adjust:none on the originating element and the ::highlight pseudo</span></div>
</body>
44 changes: 44 additions & 0 deletions forced-colors-mode/forced-colors-mode-53.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Forced colors mode - Highlight pseudos use the originating element's forced colors state</title>
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#forced-color-adjust-prop">
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
<link rel=match href="forced-colors-mode-53-ref.html">
<style>
span {
background-color: lightgray;
color: orange;
}

span::highlight(foo) {
background-color: yellow;
color: blue;
text-decoration: underline;
text-decoration-color: orange;
}

.fcaOriginating {
forced-color-adjust: none;
}

.fcaPseudo::highlight(foo) {
forced-color-adjust: none;
}
</style>
<body>
<div><span>This content doesn't have forced-color-adjust set at all</span></div>
<div><span class="fcaOriginating">This content has forced-color-adjust:none on the originating element only</span></div>
<div><span class="fcaPseudo">This content has forced-color-adjust:none on the ::highlight pseudo only</span></div>
<div><span class="fcaOriginating fcaPseudo">This content has forced-color-adjust:none on the originating element and the ::highlight pseudo</span></div>
<script>
const ranges = [];
document.querySelectorAll("div").forEach(div => {
const range = new Range();
range.setStart(div, 0);
range.setEnd(div, 1);
ranges.push(range);
})

CSS.highlights.set("foo", new Highlight(...ranges));
</script>
</body>