The innerHTML
property of the ShadowRoot
interface gets or sets the HTML markup to the DOM tree inside the ShadowRoot
.
Note that some browsers serialize the <
and >
characters as <
and >
when they appear in attribute values (see Browser compatibility). This is to prevent a potential security vulnerability (mutation XSS) in which an attacker can craft input that bypasses a sanitization function, enabling a cross-site scripting (XSS) attack.
A string.
When set to the null
value, that null
value is converted to the empty string (""
), so sr.innerHTML = null
is equivalent to sr.innerHTML = ""
.
let customElem = document.querySelector("my-shadow-dom-element");
let shadow = customElem.shadowRoot;
shadow.innerHTML = "<strong>This element should be more important!</strong>";
Specifications Browser compatibility
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4