Skip to content

Commit

Permalink
Fix issue with injected browser extension styles in waitForLoadedStyl…
Browse files Browse the repository at this point in the history
…eSheets
  • Loading branch information
ThaNarie committed Jun 11, 2020
1 parent a5891bb commit f4e9e15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "muban-core",
"version": "2.1.1",
"version": "2.1.2",
"description": "The core library and webpack loaders for Muban",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils/waitForStyleSheetsLoaded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ export const waitForLoadedStyleSheets = (document, development = false) =>
const links = Array.from<HTMLLinkElement>(
// eslint-disable-next-line no-restricted-properties
document.querySelectorAll('link[rel=stylesheet]'),
).filter((l) => !development || (l.href && l.href.startsWith('blob:')));
)
// Some sheets get injected (by extensions) that don't have a source set,
// those sheets will get the same source as the page, but will never load
.filter((l) => l.href !== document.location.href)
// during development, we want to ignore blob-sheets, as they behave weird and will load instantly anyway
.filter((l) => !development || (l.href && l.href.startsWith('blob:')));

// console.info('[WFSSL]');
// console.info('[WFSSL] ---- init ----');
// console.info('[WFSSL] links: ', links.length);
// console.info('[WFSSL] loaded: \n\t', links.map(l => `${l.href} -- ${l.sheet}`).join('\n\t '));
// console.info('[WFSSL] links: \n\t', links.map(l => `${l.href} -- ${l.href.substr(-3)} - ${l.sheet}`).join('\n\t '));

let resolved = false;
Expand Down

0 comments on commit f4e9e15

Please sign in to comment.