Loading...
const host = document.querySelector('my-card');
const html = host.innerHTML;const host = document.querySelector('my-card');
const html = host.getHTML({ serializableShadowRoots: true });innerHTML skips shadow roots; getHTML() can serialize them as <template shadowrootmode> markup.
innerHTML and wondering why the shadow DOM content is missing.getHTML({ serializableShadowRoots: true }).serializable: true.Without options they return the same markup. getHTML() can also include serializable shadow roots, or specific ones passed in shadowRoots.
Use setHTMLUnsafe(), which parses declarative shadow DOM. Sanitize the string first if it can contain user content.