custom-highlight-painting-staticrange-005.html (899B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Highlight API Test: StaticRange is repainted correctly after deleting and re-adding it.</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="A StaticRange is repainted correctly after deleting and re-adding it."> 7 <style> 8 ::highlight(example-highlight) { 9 background-color: yellow; 10 color: blue; 11 } 12 </style> 13 <body><span>One two three…</span> 14 <script> 15 let h = new Highlight(); 16 const range = new StaticRange({ 17 startContainer: document.body.firstChild.childNodes[0], 18 startOffset: 0, 19 endContainer: document.body.firstChild.childNodes[0], 20 endOffset: 8 21 }) 22 h.add(range); 23 CSS.highlights.set("example-highlight", h); 24 document.body.onload = () => { 25 h.delete(range); 26 h.add(range); 27 }; 28 </script>