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
check for typeof attribute value, if is string use setAttribute #511
check for typeof attribute value, if is string use setAttribute #511
Conversation
@@ -64,7 +64,10 @@ export function setAccessor(node, name, old, value, isSvg) { | |||
} | |||
l[name] = value; | |||
} | |||
else if (name!=='list' && name!=='type' && !isSvg && name in node) { | |||
else if (typeof value === 'string' && !isSvg && name in node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it'd be possible to invert this conditional and have String fall through to the complete attribute add/update/remove flow on line 75?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Tests ✅
Looking at the travis build, it actually seems like this might be better for performance! (not sure how but I'll take it) |
Don't forget to consider merging #495 after fixing this one. |
@enapupe yup yup, I'll pair up the two. These are likely to go into |
I was chatting with @developit about this PR today and he suggested adding a check to see if the value being set is an object and if so, falling back to using a property setter. I tried to outline the expected behavior in this comment (sorry it's a bit long!) |
Since this is opened against v8, and the original issue (#492) has been closed, I'm going to close this PR. If there is a another situation where this change would be beneficial in Preact X, open a new issue with that case, and we'll take a look. |
I wasn't able to run react tests against this change but I tried to change the logic as minimum as possible.
ref #492