From 9d562ca10e9d6a8cf59acdb4e4e631b9e0455277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr?= <8machy@seznam.cz> Date: Sun, 29 Sep 2024 20:31:33 +0200 Subject: [PATCH] Redraw children snippets, if parent snippet is only syncing attributes --- packages/signalizejs/src/modules/snippets.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/signalizejs/src/modules/snippets.js b/packages/signalizejs/src/modules/snippets.js index 4bb2516..990d16a 100755 --- a/packages/signalizejs/src/modules/snippets.js +++ b/packages/signalizejs/src/modules/snippets.js @@ -42,7 +42,6 @@ export default async ({ params, resolve, root }) => { while(snippetActions.length) { const snippetAction = snippetActions.shift(); - if (snippetAction === 'replace') { newSnippet.setAttribute(snippetStateAttribute, 'redrawing'); existingSnippet.replaceWith(newSnippet); @@ -131,9 +130,24 @@ export default async ({ params, resolve, root }) => { while (snippets.length > 0) { const newSnippet = snippets.shift(); + const parentSnippet = newSnippet?.parentNode?.closest(`[${snippetAttribute}]`); + if (parentSnippet) { + const parentSnippetActions = parentSnippet.getAttribute(snippetActionAttribute) ?? null; + let shouldSkipSnippet = parentSnippetActions === null; + + if (!shouldSkipSnippet) { + for(const action of ['replace', 'replace-children', 'append-children', 'prepend-children']) { + shouldSkipSnippet = parentSnippetActions.includes(action); + + if (shouldSkipSnippet) { + break; + } + } + } - if (newSnippet?.parentNode?.closest(`[${snippetAttribute}]`) !== null) { - continue; + if (shouldSkipSnippet) { + continue; + } } redrawPromisses.push(redrawSnippet(newSnippet));