File: highlight-text-cascade.html

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (35 lines) | stat: -rw-r--r-- 1,430 bytes parent folder | download | duplicates (7)
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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Multiple custom highlight pseudo elements.</title>
    <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#creating-highlights">
    <link rel="match" href="highlight-text-cascade-ref.html">
    <meta name="assert" content="Multiple highlights should be able to be specified.">
    <style>
        #out::highlight(example-highlight) {
            background-color: yellow;
            color:green;
        }
        #scoped::highlight(example-highlight) {
            background-color: blue;
            color:red;
        }
    </style>
</head>
<body>
    <div id="out"><span id="text1">One two three</span></div>
    <div id="scoped"><span id="text2">four five six</span></div>
    <span id="text3">seven eight nine</span>

    <script>
        let textElement1 = document.getElementById('text1');
        let textElement2 = document.getElementById('text2');
        let textElement3 = document.getElementById('text3');
        let highlight = new Highlight(new StaticRange({startContainer: textElement1.childNodes[0], startOffset: 0, endContainer: textElement1.childNodes[0], endOffset: 3}));
        highlight.add(new StaticRange({startContainer: textElement2.childNodes[0], startOffset: 5, endContainer: textElement2.childNodes[0], endOffset: 9}));

        CSS.highlights.set("example-highlight", highlight);
    </script>
</body>
</html>