-
-
Notifications
You must be signed in to change notification settings - Fork 926
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 tiny bugs of setAttr()/updateStyle() #2988
base: main
Are you sure you want to change the base?
Conversation
I am a little sorry for my frequent pull requests these days.😢 I think these are bugs that almost no one cares about, so I won't hurry you to review or merge it. |
edc6ab8
to
2ae7003
Compare
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.
You still need to fix the diff algorithm (this will have negative perf impact) to compare is
values for non-custom element vnodes.
- If the
is
attribute disappears, the element needs replaced so it's no longer a custom element. - If the
is
attribute is newly added, the element needs replaced so it's now a custom element. - If the
is
attribute changes, the backing custom element needs to change to be that new type.
In all three cases, it's simpler and more predictable to just remove and re-create.
@dead-claudia I think I will close this PR for now. There is no hurry at all to fix the other bugs in this PR. |
@kfule The current behavior isn't any more "predictable". What I suggested was really just a one line fix plus some more (pretty straightforward) tests. Sorry if this wasn't clear. |
This allows the "is" attribute to be set or removed like any other attribute.
This is a leftover from MithrilJS#2811.
2ae7003
to
f944a7e
Compare
@dead-claudia The following changes related to attr/style have been added to the previous PR. Both are small changes, I think.
I have not added any tests, but I would like to add tests if needed. Also, I thought about your comment about "is" being "unpredictable".
However, I personally would be more careful about adding code to this area because of the performance impact (about a several percent drop). |
@kfule Try adding a A bit test from a field allocated inline in the object is very cheap. It's only a few bottlenecking instructions (4-6 at most) in the fast path plus an extra immediate generation + memory store (that won't bottleneck), so it should avoid significant perf deviations. You'll also have to do a |
This seems to give better performance than simply adding a `(old.attrs && old.attrs.is) == (vnode.attrs && vnode.attrs.is)` evaluation to updateNode().
Fixed a few tiny bugs in attributes and style properties updates.
Description
key === "is"
fromsetAttr()
to fix 2799 Custom elements: built-in element extensions lose theiris
attribute #2799 (comment)key === "is"
is removed from removeAttr() as well.Motivation and Context
I found a strange behavior in the process of #2985, although it rarely happens (#2985 (comment)). And there seems to be a similar trivial issue in
updateAttrs()
(flems.)This could be solved by simply swapping the order of set and removal probably without creating new bugs and perf issues.
Also, I am not very familiar with custom elements, but it seemed to me that the #2799 issue could be solved by simply removing
key === "is"
fromsetAttr()
.How Has This Been Tested?
npm run test
including test code fix for custom elementsTypes of changes
Checklist