highlight-api-orphan-node-crash.html (662B)
1 <!doctype html> 2 <title>Custom Highlight with range anchored in orphan shadow node can be registered without crashing</title> 3 <meta name="author" title="Fernando Fiori" href="mailto:ffiori@microsoft.com"> 4 <script> 5 const host = document.createElement("div"); 6 const shadow = host.attachShadow({ mode: "open" }); 7 const spanInShadowDOM = document.createElement("span"); 8 spanInShadowDOM.textContent = "Hello, world."; 9 shadow.appendChild(spanInShadowDOM); 10 let range = new Range(); 11 range.setStart(spanInShadowDOM.childNodes[0], 0); 12 range.setEnd(spanInShadowDOM.childNodes[0], 5); 13 CSS.highlights.set("example-highlight", new Highlight(range)); 14 </script>