-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Move HTML/ARIA property/attribute reflection from ssr-compiler
to ssr-runtime
#4641
Comments
This issue has been linked to a new work item: W-16985169 |
Interestingly, const div = document.createElement('div')
// <div></div>
div.ariaLabel = div.title = 'foo'
// <div aria-label="foo" title="foo"></div>
div.ariaLabel = div.title = null
// <div title="null"></div> |
I think it varies from attribute to attribute. E.g. setting lwc/packages/@lwc/integration-karma/test/component/html-properties/index.spec.js Lines 133 to 136 in 6d0296b
|
That's variation on the value, not variation on removal. const div = document.createElement('div')
// <div></div>
div.ariaLabel = div.title = div.spellcheck = div.tabIndex = 'foo'
// <div aria-label="foo" title="foo" spellcheck="true" tabindex="0"></div>
div.ariaLabel = div.title = div.spellcheck = div.tabIndex = null
div.hasAttribute('aria-label') // false
div.hasAttribute('title') // true
div.hasAttribute('spellcheck') // true
div.hasAttribute('tabindex') // true |
Right now the property/attribute reflection in the
ssr-
packages is a bit hairy. I don't think that we need to sniff at runtime which props are present in the component (title
,ariaLabel
, etc.) – we can just move the known lists of global HTML props / ARIA props tossr-runtime
and put them all on a shared prototype (or similar mechanism). This will simplify the SSR compiler code quite a bit.Another small bug: calling
(etc)
should result in the corresponding attributes being removed, same as setting
null
. This is just how HTML IDL attribute reflection works. Currently this is busted for ARIA properties because@lwc/aria-reflection
doesn't handleundefined
correctly for backwards compat.The text was updated successfully, but these errors were encountered: