Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace DOMNodeInserted with MutationObserver for dynamic content han… #1

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

JoDerGraf
Copy link
Collaborator

@JoDerGraf JoDerGraf commented Jul 29, 2024

The DOMNodeInserted event is deprecated and no longer supported in recent versions of Chrome (e.g., Chrome 127 and later). This commit updates the code to use MutationObserver, which is a modern and recommended way to observe changes in the DOM.

The MutationObserver is set up to monitor changes in the document and specifically look for newly added nodes with the class collection-item. When such nodes are detected, the Redactor editor is initialized for these elements.

This change ensures compatibility with newer browser versions and improves performance and reliability when handling dynamic content.

Changes made:

  • Replaced DOMNodeInserted event listener with a MutationObserver.
  • Updated the callback function to initialize Redactor editors for dynamically added collection items.

…dling

The `DOMNodeInserted` event is deprecated and no longer supported in recent versions of Chrome (e.g., Chrome 127 and later). This commit updates the code to use `MutationObserver`, which is a modern and recommended way to observe changes in the DOM.

The MutationObserver is set up to monitor changes in the document and specifically look for newly added nodes with the class `collection-item`. When such nodes are detected, the Redactor editor is initialized for these elements.

This change ensures compatibility with newer browser versions and improves performance and reliability when handling dynamic content.

Changes made:
- Replaced `DOMNodeInserted` event listener with a `MutationObserver`.
- Updated the callback function to initialize Redactor editors for dynamically added collection items.
@JoDerGraf JoDerGraf merged commit 69e10e1 into master Jul 29, 2024
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.

1 participant