Skip to content

Commit

Permalink
Update embed.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
doug committed Jul 10, 2020
1 parent 14d4721 commit 7ecdfa5
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/embed.ts
Expand Up @@ -229,18 +229,12 @@ async function loadOpts(opt: EmbedOptions, loader: Loader): Promise<EmbedOptions
};
}

function getRoot(el: Element) {
const possibleRoot = el.getRootNode ? el.getRootNode() : document;
let root: ShadowRoot | Document;
let rootContainer: Element | ShadowRoot;
function getRoot(el: Element): {root: ShadowRoot | Document, rootContainer: Element | ShadowRoot} {
const root = el.getRootNode ? el.getRootNode() : document;
if (possibleRoot instanceof ShadowRoot) {
root = possibleRoot;
rootContainer = root;
} else {
root = document;
rootContainer = root.head ?? root.body;
return {root, rootContainer: root};
}
return { root, rootContainer };
return {root: document, rootContainer: document.head ?? document.body};
}

async function _embed(
Expand Down

0 comments on commit 7ecdfa5

Please sign in to comment.