summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-highlight-api/painting/custom-highlight-painting-priority-text-decoration-001.html
blob: 7ab318b5a118c46af4e4a01f146240d433fa8a5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
    <title>CSS Highlight API Test: ::highlight text-decoration paints over higher priority when not clashing</title>
    <link rel="help" href="https://www.w3.org/TR/css-highlight-api-1/#priorities">
    <link rel="match" href="custom-highlight-painting-priority-text-decoration-001-ref.html">
    <style>
    ::highlight(yellow-highlight) {
        background-color: yellow;
    }
    ::highlight(underline-highlight) {
        text-decoration: underline;
        text-decoration-color: red;
    }
    </style>
</head>
<body>
    <span id="yellow-highlight">Yellow</span>

    <script>
        let yellow = document.getElementById("yellow-highlight");
        let highlightYellow = new Highlight(new StaticRange({
            startContainer: yellow.childNodes[0],
            startOffset: 0,
            endContainer: yellow.childNodes[0],
            endOffset: 6
        }));
        let highlightUnderline = new Highlight(new StaticRange({
            startContainer: yellow.childNodes[0],
            startOffset: 0,
            endContainer: yellow.childNodes[0],
            endOffset: 6
        }));
        CSS.highlights.set("yellow-highlight", highlightYellow);
        CSS.highlights.set("underline-highlight", highlightUnderline);
        highlightYellow.priority = 10;
    </script>
</body>
</html>