Skip to content

Commit bcb6a30

Browse files
committed
Fix loadingDirectives match elements from nested components
1 parent b07f864 commit bcb6a30

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,8 @@ class LoadingPlugin {
24032403
}
24042404
getLoadingDirectives(element) {
24052405
const loadingDirectives = [];
2406-
let matchingElements = element.querySelectorAll('[data-loading]');
2406+
let matchingElements = [...element.querySelectorAll('[data-loading]')];
2407+
matchingElements = matchingElements.filter((elt) => elt.closest('[data-controller="live"]') === element);
24072408
if (element.hasAttribute('data-loading')) {
24082409
matchingElements = [element, ...matchingElements];
24092410
}

src/LiveComponent/assets/src/Component/plugins/LoadingPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ export default class implements PluginInterface {
150150

151151
getLoadingDirectives(element: HTMLElement|SVGElement) {
152152
const loadingDirectives: ElementLoadingDirectives[] = [];
153-
let matchingElements = element.querySelectorAll('[data-loading]');
153+
let matchingElements = [...element.querySelectorAll('[data-loading]')];
154+
155+
// ignore elements which are inside a nested "live" component
156+
matchingElements = matchingElements.filter((elt) => elt.closest('[data-controller="live"]') === element);
154157

155158
// querySelectorAll doesn't include the element itself
156159
if (element.hasAttribute('data-loading')) {

0 commit comments

Comments
 (0)