bug #17262 Replace deprecated DOMNodeInserted event with MutationObserver (kulczy)

This PR was merged into the 1.13 branch.

Discussion
----------

This PR replaces the use of the deprecated (started from Chrome 130) `DOMNodeInserted` event with the modern `MutationObserver` API


Commits
-------

daf2c910d4 Replace deprecated DOMNodeInserted event with MutationObserver
012f2e56e3 Revert "[Behat] Temporarily add todo tag to problematic scenarios"
This commit is contained in:
Grzegorz Sadowski 2024-10-17 14:15:59 +02:00 committed by GitHub
commit 226348bfe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 11 deletions

View file

@ -9,8 +9,7 @@ Feature: Adding a new promotion with action configured in different channels
And the store also operates on another channel named "Web-GB" in "GBP" currency
And I am logged in as an administrator
# Temporarily disable in UI context because of the timeout exceptions in build
@api @todo-ui @mink:chromedriver
@ui @mink:chromedriver @api
Scenario: Adding a new promotion with item fixed discount
When I want to create a new promotion
And I specify its code as "20_for_all_products"

View file

@ -9,8 +9,7 @@ Feature: Adding a new promotion with rule configured in different channels
And the store operates on a channel named "Web-GB" in "GBP" currency
And I am logged in as an administrator
# Temporarily disable in UI context because of the timeout exceptions in build
@api @todo-ui @mink:chromedriver
@api @ui @mink:chromedriver
Scenario: Adding a new promotion with total price of items
When I want to create a new promotion
And I specify its code as "100_IN_EVERY_CURRENCY"

View file

@ -122,14 +122,31 @@ $(document).ready(() => {
$(document).previewUploadedImage('#add-avatar');
$('body').on('DOMNodeInserted', '[data-form-collection="item"]', (event) => {
if ($(event.target).find('.ui.accordion').length > 0) {
$(event.target).find('.ui.accordion').accordion();
}
if ($(event.target).find('.ui.tabular.menu').length > 0) {
$(event.target).find('.ui.tabular.menu .item').tab();
}
const newNodeObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes.length > 0) {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
const formCollectionItem = node.closest('[data-form-collection="item"]');
if (formCollectionItem) {
if ($(formCollectionItem).find('.ui.accordion').length > 0) {
$(formCollectionItem).find('.ui.accordion').accordion();
}
if ($(formCollectionItem).find('.ui.tabular.menu').length > 0) {
$(formCollectionItem).find('.ui.tabular.menu .item').tab();
}
}
}
});
}
});
});
const observerConfig = {
childList: true,
subtree: true,
};
const targetNode = document.querySelector('body');
newNodeObserver.observe(targetNode, observerConfig);
const taxonomyTree = new SyliusTaxonomyTree();