-
Notifications
You must be signed in to change notification settings - Fork 179
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
Don't use localName to identify tags, if it's not populated #498
base: master
Are you sure you want to change the base?
Conversation
Don't use localName to identify tags, if it's not populated. I verified this issue on Cobalt 9, but this may also affect IE <=8. https://caniuse.com/?search=localName In browsers that don't populate localName, idom couldn't identify the tag name during patch, and would always think that a different tag was being re-rendered, always recreating DOM nodes rather than reusing them (you can't change the tag name of an existing node). Quick links: Element.localName https://developer.mozilla.org/en-US/docs/Web/API/Element/localName Node.nodeName https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName Element.tagName https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName
Remove runtime Element check and force TypeScript to access `localName`. Changed check to use `??` after I verified that localName is not the empty string
|
I'm sorry, I'm not familiar with the idom implementation. I don't understand what I would need to fix. |
const d = document.createElement('div');
assert.equal(d.nodeName, 'DIV');
assert.equal(d.localName, 'div'); This is particularly important for SVG, which has case-sensitive element names. Eg, In short, everywhere that reads NodeData.nameOrCtor will need to be updated to handle the fact that we can read either a correclty-cased
If you were delete the |
Don't use
localName
to identify tags, if it's not populated.In browsers that don't populate
localName
, idom couldn't identify the tag name during patch, and would always think that a different tag was being re-rendered, always recreating DOM nodes rather than reusing them (you can't change the tag name of an existing node).I verified this issue on Cobalt 9, but this may also affect IE <=8 and other old browsers. https://caniuse.com/?search=localName
Quick links:
Element.localName
https://developer.mozilla.org/en-US/docs/Web/API/Element/localNameNode.nodeName
https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeNameElement.tagName
https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName