Skip to content

Commit 0205629

Browse files
[BUGFIX] Register consecutively created drag uploaders
The jQuery removal in #102415 removed the MutationObserver, breaking the registration of consecutively created drag uploaders, e.g. in IRRE items. The MutationObserver is added again to solve this issue, but reveals that the code needs a complete overhaul as needing a MutationObserver for this use-case is too much. Resolves: #105755 Related: #102415 Releases: main, 13.4 Change-Id: I5dc2766d7a3a960903493b66332e874ebf9d3650 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/87409 Reviewed-by: Garvin Hicking <gh@faktor-e.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Andreas Kienast <akienast@scripting-base.de> Tested-by: Garvin Hicking <gh@faktor-e.de> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Andreas Kienast <akienast@scripting-base.de> Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
1 parent e347dc7 commit 0205629

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Build/Sources/TypeScript/backend/drag-uploader.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ export default class DragUploader {
233233
}
234234

235235
public static init(): void {
236+
const observer = new MutationObserver((mutations: MutationRecord[]): void => {
237+
for (const mutation of mutations) {
238+
if (mutation.type === 'childList') {
239+
for (const node of [...mutation.addedNodes.values()]) {
240+
if (!(node instanceof HTMLElement)) {
241+
continue;
242+
}
243+
if (node.matches('.t3js-drag-uploader')) {
244+
new DragUploader(node);
245+
} else {
246+
node.querySelectorAll('.t3js-drag-uploader').forEach((element: HTMLElement): void => {
247+
new DragUploader(element);
248+
});
249+
}
250+
}
251+
}
252+
}
253+
});
254+
observer.observe(document, { childList: true, subtree: true });
255+
236256
DocumentService.ready().then((): void => {
237257
document.querySelectorAll('.t3js-drag-uploader').forEach((element: HTMLElement): void => {
238258
new DragUploader(element);

0 commit comments

Comments
 (0)