Skip to content

Fix DomNodeInserted Deprecation - #22

Closed
PelledeGreeuw wants to merge 2 commits into
monim67:masterfrom
PelledeGreeuw:fix-domnodeinserted-deprecation
Closed

Fix DomNodeInserted Deprecation#22
PelledeGreeuw wants to merge 2 commits into
monim67:masterfrom
PelledeGreeuw:fix-domnodeinserted-deprecation

Conversation

@PelledeGreeuw

Copy link
Copy Markdown

Fix DomNodeInserted Deprecation

Purpose

The MutationEvent API has been deprecated (#21) and some browsers already dropped support completely MDN. This causes a warning in the developer console and prevents flatpickrs which are inserted through e.g. a modal (#16 ) from being initialized.

Approach

Removed the DOMNodeInserted event listener and replaced it with a MutationObserver

Issues solved in this PR

What has Changed

  • django-flatpickr.js

@monim67

monim67 commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Thanks for tackling this! While testing, I found this approach doesn't fully fix #16: observing document.body with childList: true (no subtree) only catches nodes added directly as children of <body>. In practice, modal content is usually inserted nested inside an existing wrapper element already in the DOM, not as a direct child of <body> — so that case is still missed.

I've opened #24 with a MutationObserver on document with subtree: true, which catches nested insertions as well and still fixes the DOMNodeInserted deprecation (#21). Verified both approaches side by side with a small reproduction harness.

I'll go ahead and close this in favor of #24 — happy to revisit if I've misjudged something here.

@monim67 monim67 closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants