Skip to content

Commit

Permalink
fix: 修复内容元素被重复监听变化的问题 (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: jixianjing <xianjing.ji@mail.hypers.com>
  • Loading branch information
BlindMonkLeeSin and jixianjing committed Mar 2, 2023
1 parent 2c56928 commit 2af89fc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,18 @@ class Nav extends React.PureComponent<Props, State> {
}
if (content) {
if (window.MutationObserver) {
this.observe = new MutationObserver(() => {
if (!this.props.once) {
this.reload();
}
});
const config = {
childList: true,
subtree: true
};
this.observe.observe(content, config);
if (!this.observe) {
this.observe = new MutationObserver(() => {
if (!this.props.once) {
this.reload();
}
});
const config = {
childList: true,
subtree: true
};
this.observe.observe(content, config);
}
} else {
this.prevInnerHTML = content.innerHTML;
}
Expand Down

1 comment on commit 2af89fc

@vercel
Copy link

@vercel vercel bot commented on 2af89fc Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

document-nav – ./

document-nav-git-master-rsuite.vercel.app
document-nav-rsuite.vercel.app

Please sign in to comment.