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

Only update each blocks when their dependencies have changed #489

Merged
merged 11 commits into from
Apr 17, 2017

Conversation

Rich-Harris
Copy link
Member

Ref #381. So far, I'm just refactoring the each-block code, because it's grown a little bit wild and woolly. The work done for this PR (identifying which dependencies a fragment has) should also support #472

@Rich-Harris
Copy link
Member Author

Alright, I think this is ready to go — am going to start work on #472 in parallel.

This PR involves a bit of a shift in how things happen. We first traverse the markup AST in a 'preprocess' step, which creates blocks (as before, with block.child(...)) but then attaches them to the node in question as node_block. Any time an expression is encountered (in a tag, a binding, an attribute, an if block or an each block), the expression's dependencies are added to the current block (and all parent blocks — so the top-level block has the largest number of dependencies).

This way, by the time we visit the node, we already know if it contains any dynamic content, and which properties to check for changes before updating if it does have dynamic content.

@Rich-Harris Rich-Harris changed the title [WIP] Only update each blocks when their dependencies have changed Only update each blocks when their dependencies have changed Apr 17, 2017
@Rich-Harris Rich-Harris merged commit aeedb94 into master Apr 17, 2017
@Rich-Harris Rich-Harris deleted the gh-381 branch April 17, 2017 19:15
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.

1 participant