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 inputs when the value changed #1703

Merged
merged 1 commit into from
Aug 28, 2018

Conversation

TehShrike
Copy link
Member

Fixes #1699

I originally started adding new conditions to the array in Elements.ts, but once I figured out where to get the dependencies from, it seemed to make more sense to do it in Bindings.ts to keep from exposing anything more from the munge method.

I didn't add any new tests, I updated/was guided by the existing test suite. I could add a new test if someone can think of an appropriate one.

Copy link
Contributor

@jacwright jacwright left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -129,14 +129,24 @@ export default class Binding extends Node {
updateDom = null;
}

const dependencyArray = [...this.value.dependencies]

if (dependencyArray.length === 1) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not positive that it's needed, but using quotePropIfNecessary here seems like a good idea.

Copy link
Contributor

@jacwright jacwright Aug 28, 2018

Choose a reason for hiding this comment

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

We aren't quoting change.${prop} in most areas of the app because, for the most part, you cannot reference something that needs quotes in expressions in the template. The exception is when shorthands are used, such as:

<Comp :my-shorthand-binding-var-has-dashes/>
<div class:my-class-name-shorthand-has-dashes></div>

So do shorthand bindings come through here? If so, I agree, we need to quotePropIfNecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

These dependency prop strings are the same ones used like ctx.${prop} a bit further down, so I felt comfortable not looking for a quote function.

@Rich-Harris Rich-Harris merged commit 3c9d4b2 into sveltejs:master Aug 28, 2018
@Rich-Harris
Copy link
Member

🤘

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.

4 participants