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

[Pivots] attributeChangedCallback should handle reflected properties #2994

Closed
nolanlawson opened this issue Aug 9, 2022 · 6 comments
Closed
Labels

Comments

@nolanlawson
Copy link
Collaborator

Description

(This only applies to pivots (#2724).)

Pivots implement their own patch for attributeChangeCallback and observedAttributes, by overriding setAttribute/removeAttribute. But this doesn't handle Element properties that reflect to/from attributes, such as ariaLabel:

customElements.define('x-foo', class extends HTMLElement {
    static observedAttributes = ['aria-label']
    attributeChangedCallback(name, old, updated) {
      console.log('attribute changed')
    }
})

const elm = document.createElement('x-foo')
elm.ariaLabel = 'bar' // triggers attributeChangedCallback

Note that this only applies to custom elements whose tag names conflict with another custom element. Non-conflicting custom elements don't override any native attribute behavior.

@nolanlawson nolanlawson changed the title [Pivots] attributeChangeCallback should handle reflected properties [Pivots] attributeChangedCallback should handle reflected properties Aug 9, 2022
@git2gus
Copy link

git2gus bot commented Aug 11, 2022

This issue has been linked to a new work item: W-11585211

@nolanlawson
Copy link
Collaborator Author

Pivots were dropped in #3310

@caridy
Copy link
Contributor

caridy commented Jan 30, 2023

@nolanlawson just curious here, if the UA supports such reflections, why would this not work as expected then? cc @rwaldron

@nolanlawson
Copy link
Collaborator Author

@caridy We override setAttribute/removeAttribute/getAttribute, but we don't override the getter/setter on e.g. ariaLabel.

So I believe doing elm.ariaLabel = 'foo' on an element with static observedAttributes = ['aria-label'] would work in native but not with our pivots implementation.

@caridy
Copy link
Contributor

caridy commented Feb 3, 2023

oh, I see... it is not really about aria, the same happens for elm.title = newTitle. Got it. I think we can still try to cover that, but seems very difficult to do it. We can chat more about it. cc @rwaldron

@nolanlawson
Copy link
Collaborator Author

Yes, good point. Also id, value, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants