Skip to content

Commit

Permalink
Issue #34: Adding debug details when skipping attribute mutation obse…
Browse files Browse the repository at this point in the history
…rver.
  • Loading branch information
patricknelson committed Dec 5, 2023
1 parent 335ff8d commit 5b99368
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,17 @@ export default function svelteRetag(opts) {
// Setup mutation observer to watch for changes to attributes on this element (if not already done) now that we
// know the full set of component props. Only do this if configured and if the observer hasn't already been setup
// (since we can render an element multiple times).
if (opts.attributes === true && !this.attributesObserved && this.propMap.size > 0) {
attributeObserver.observe(this, {
attributes: true,
attributeFilter: [...this.propMap.keys()],
});
if (opts.attributes === true && !this.attributesObserved) {
this.attributesObserved = true;
if (this.propMap.size > 0) {
attributeObserver.observe(this, {
attributes: true, // implicit, but... 🤷‍♂️
attributeFilter: [...this.propMap.keys()],
});
} else {
// No props to observe, so no point in setting up the observer.
this._debug('renderSvelteComponent(): skipped attribute observer, no props');
}
}


Expand Down

0 comments on commit 5b99368

Please sign in to comment.