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

[Custom Elements] Calling setAttribute with a non-lower cased attribute name does not trigger attributeChangedCallback #110

Open
sorvell opened this issue Aug 5, 2018 · 4 comments

Comments

@sorvell
Copy link
Collaborator

sorvell commented Aug 5, 2018

If foo is in observedAttributes and setAttribute('FoO', '2') is called, in Chrome with native custom elements, the attributeChangedCallback is called with the attribute name set to foo (lowercased). When using the custom elements polyfill, the attributeChangedCallback is not called..

See: http://jsbin.com/fiyufid/edit?html,console,output

kevinpschaaf referenced this issue in lit/lit-element Dec 17, 2018
* Changes property options to support `converter`

Fixes #264

Changes `type` to be only a hint to the `converter` option which has the previous `type` functionality, an object with `toAttribute` and `fromAttribute` or just a function which is `fromAttribute`. In addition to the `value` these functions now also get the property's `type`.

Also provides a default converter that supports `Boolean`, `String`, `Number`, `Object`, and `Array` out of the box.

In addition, numbers and strings now become `null` if their reflected attribute is removed.

* Format

* Address review feedback

* Update CHANGELOG.md

* Clarify documentation about default converter

* Format

* Fix test to use lowercase attribute names

This is working around https://github.com/webcomponents/custom-elements/issues/167.

* Fix test on IE

* Address review feedback

Remove superfluous null checks

* Makes reflection more consistent

Previously, when an attribute changed as a result of a reflecting property changing, the property was prevented from mutating again as can happen when a custom `converter` is used.

Now, the oppose is also true. When a property changes as a result of an attribute changing, the attribute is prevented from mutating again

This change helps ensure that when a user calls `setAttribute`, a `converter.toAttribute` does not cause the attribute to immediately mutate. This is unexpected behavior and this change discourages it.

* Format.

* Address review feedback.

* Address review feedback

Ensure Object/Array properties respect `undefined` (no change to attribute) and `null` (remove attribute) values.
@dfreedm dfreedm transferred this issue from webcomponents/custom-elements Jun 7, 2019
@dfreedm dfreedm changed the title Calling setAttribute with a non-lower cased attribute name does not trigger attributeChangedCallback [Custom Elements] Calling setAttribute with a non-lower cased attribute name does not trigger attributeChangedCallback Jun 12, 2019
@bicknellr
Copy link
Collaborator

#136

@stale
Copy link

stale bot commented Jun 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 12, 2020
@stale
Copy link

stale bot commented Jun 23, 2022

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

@stale stale bot closed this as completed Jun 23, 2022
@bicknellr bicknellr reopened this Jun 23, 2022
@stale stale bot removed the wontfix label Jun 23, 2022
@stale
Copy link

stale bot commented Aug 12, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants