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

Fix attributes diff on DOM node #677

Merged
merged 3 commits into from
May 25, 2017
Merged

Conversation

dmail
Copy link
Contributor

@dmail dmail commented Apr 27, 2017

Expected behaviour

Diff should remove attributes when they are no longer present in the next html state (see unit test)

Actual behaviour

It behaves as expected when the merged node is created using h.
It preserves removed attributes when the merged node comes from the DOM.

Possible solutions

  • I suggest to approve this pull request :)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 15cf5cc on dmail-fork:master into c4f3fb0 on developit:master.

src/vdom/diff.js Outdated
@@ -124,6 +124,8 @@ function idiff(dom, vnode, context, mountAll, componentRoot) {
props = out[ATTR_KEY] || (out[ATTR_KEY] = {}),
vchildren = vnode.children;

for (let a=out.attributes, i=a.length; i--; ) props[a[i].name] = a[i].value;
Copy link
Member

Choose a reason for hiding this comment

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

we'll need to wrap this in a check for props. If the propcache already exists on an element, skipping attribute checks is a fairly major performance gain.

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 fine doing this post-merge if you want.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4f816a1 on dmail-fork:master into abcdcda on developit:master.

Damien Maillard and others added 2 commits May 2, 2017 10:53
Added the Periodic Weather PWA with the lastest of Preact to the list! ☀️
@dmail
Copy link
Contributor Author

dmail commented May 2, 2017

@developit code updated to loop over attributes only when not cached : https://github.com/developit/preact/pull/677/files#diff-a0896fa5d65b1d80ca4d496badbae50fR127

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 1d8c474 on dmail-fork:master into 9001436 on developit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 5122ca9 on dmail-fork:master into 5b6c21b on developit:master.

props = out[ATTR_KEY];
}
else {
props = out[ATTR_KEY] = {};
Copy link
Member

Choose a reason for hiding this comment

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

I'll probably consolidate this post-merge, but it's good!

@developit developit merged commit a260174 into preactjs:master May 25, 2017
@dmail
Copy link
Contributor Author

dmail commented Jun 12, 2017

Hi @developit, is there a planned release with this fix ?

@developit
Copy link
Member

Yup, 8.2 out soon.

@timmywil
Copy link

@developit would love that release!

@developit
Copy link
Member

Me too, heh.

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.

None yet

5 participants