Skip to content

Commit

Permalink
unobserve the observer
Browse files Browse the repository at this point in the history
  • Loading branch information
abilicz committed Nov 29, 2023
1 parent 775a139 commit 12a817a
Show file tree
Hide file tree
Showing 2 changed files with 14,981 additions and 9,699 deletions.
16 changes: 14 additions & 2 deletions .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ const registerStory = (filename) => {
.add(name, () => ({
name: 'StoryWrapper',
components: component.components,
data() {
return {
observer: null
}
},
mounted() {
const targetNode = document.querySelector("html");
const config = { attributes: true };
Expand All @@ -69,8 +74,15 @@ const registerStory = (filename) => {
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
if (!this.observer) {
this.observer = new MutationObserver(callback);
this.observer.observe(targetNode, config);
}
},
beforeDestroy() {
if (this.observer) {
this.observer.disconnect();
}
},
render(h) {
return h(component, { style: { padding: '20px' } });
Expand Down
Loading

0 comments on commit 12a817a

Please sign in to comment.