Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patchBetween() #455

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

justinfagnani
Copy link

This adds a patchBetween(startNode, endNode, template, data) function that can run a patch function in between two nodes.

assertNoUnclosedTags(currentParent, endNode);
}
}
if (currentNode && currentNode.nextSibling !== endNode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to have unvisited dom but currentNode.nextSibling === endNode.

{template a}

{if $a}
{else} {/if}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand on that a bit? What would the unvisited DOM be? What are the idom opcode that produce it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be

function fn(a:boolean) {
elementOpen('div', 1);
elementClose();
if (a) {
elementOpen('div', 2);
elementClose();
} else {
elementOpen('div', 3);
elementClose();
}
elementOpen('div', 4);
elementClose();
}

In the first route (A), you'd have

if you flip a to false, you'd first have, I think, the following behavior

<-- insert

then the jump to 4

<-- insert
<--

and then never deleting [key=2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants