Skip to content

Commit

Permalink
fix(css-shim): check for MutationObserver (#2140)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdmacrae authored and adamdbradley committed Jan 15, 2020
1 parent 52ecd54 commit f5140c4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/client/polyfills/css-shim/load-link-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export function loadDocument(doc: Document, globalScopes: CSSScope[]) {
}

export function startWatcher(doc: Document, globalScopes: CSSScope[]) {
const mutation = new MutationObserver(() => {
if (loadDocumentStyles(doc, globalScopes)) {
updateGlobalScopes(globalScopes);
}
});
mutation.observe(document.head, { childList: true });
if (typeof MutationObserver !== 'undefined') {
const mutation = new MutationObserver(() => {
if (loadDocumentStyles(doc, globalScopes)) {
updateGlobalScopes(globalScopes);
}
});
mutation.observe(document.head, { childList: true });
}
}

export function loadDocumentLinks(doc: Document, globalScopes: CSSScope[]) {
Expand Down

0 comments on commit f5140c4

Please sign in to comment.