custom-highlight-painting-009.html (988B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Highlight API Test: </title> 4 <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/"> 5 <link rel="match" href="custom-highlight-painting-001-ref.html"> 6 <meta name="assert" value="Highlight is repainted correctly when collapsing a Range after registering a Highlight that contains it in the HighlightRegistry"> 7 <style> 8 ::highlight(example-highlight) { 9 background-color: yellow; 10 color: blue; 11 } 12 ::highlight(another-highlight) { 13 background-color: red; 14 color: orange; 15 } 16 </style> 17 <body><span>One </span><span>two </span><span>three…</span> 18 <script> 19 let r1 = new Range(); 20 r1.setStart(document.body, 0); 21 r1.setEnd(document.body, 2); 22 let r2 = new Range(); 23 r2.setStart(document.body, 1); 24 r2.setEnd(document.body, 3); 25 let h1 = new Highlight(r1); 26 let h2 = new Highlight(r2); 27 CSS.highlights.set("example-highlight", h1); 28 CSS.highlights.set("another-highlight", h2); 29 r2.collapse(); 30 </script>