Skip to content

Commit d764aff

Browse files
committed
Observe childList (added nodes) before attribute changes
1 parent c3ee75b commit d764aff

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/StimulusBundle/assets/src/loader.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class StimulusLazyControllerHandler {
8383
new MutationObserver((mutationsList) => {
8484
for (const { attributeName, target, type } of mutationsList) {
8585
switch (type) {
86+
case 'childList': {
87+
this.lazyLoadExistingControllers(target as Element);
88+
break;
89+
}
90+
8691
case 'attributes': {
8792
if (
8893
attributeName === controllerAttribute &&
@@ -92,12 +97,6 @@ class StimulusLazyControllerHandler {
9297
this.loadLazyController(controllerName)
9398
);
9499
}
95-
96-
break;
97-
}
98-
99-
case 'childList': {
100-
this.lazyLoadExistingControllers(target as Element);
101100
}
102101
}
103102
}

0 commit comments

Comments
 (0)