Skip to content

Commit

Permalink
fix: ensure onStylesLoaded callback is fired consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Apr 16, 2024
1 parent e50ef03 commit ae0f903
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/AutoFrameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,9 @@ const CopyHostStyles = ({

const collectedStyles = collectStyles(parentDocument);

let mountedCounter = 0;

Promise.all(
collectedStyles.map(async (styleNode) => {
const mirror = await mirrorEl(styleNode, () => {
mountedCounter += 1;
if (mountedCounter === collectedStyles.length) {
onStylesLoaded();
}
});
const mirror = await mirrorEl(styleNode);

if (!mirror) return;

Expand All @@ -237,6 +230,8 @@ const CopyHostStyles = ({

hashes[elHash] = true;
});

onStylesLoaded();
});

return () => {
Expand Down

0 comments on commit ae0f903

Please sign in to comment.