Skip to content

Commit

Permalink
Redraw children snippets, if parent snippet is only syncing attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Machy8 committed Sep 29, 2024
1 parent 6feb9b1 commit 9d562ca
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/signalizejs/src/modules/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9d562ca

Please sign in to comment.