Skip to content

[scoped-custom-element-registry] Non-string Values Are Not Properly Stringified Before Calling attributeChangedCallback in setAttribute #607

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

Open
oscarmarina opened this issue Jan 24, 2025 · 0 comments · May be fixed by #616 or #621

Comments

@oscarmarina
Copy link

oscarmarina commented Jan 24, 2025

Description

The patched class setAttribute calls attributeChangedCallback without converting value to a string. This can lead to unexpected behavior when passing numeric or otherwise non-string values.

Example

Playground

Steps to reproduce

Expected behavior

Similar to toggleAttribute, a preliminary step const newValue = this.getAttribute(name) is added for use in attributeChangedCallback.

Image

Actual behavior

Image
denilsonsa added a commit to denilsonsa/polyfills that referenced this issue May 7, 2025
…ute()

Any value set via `setAttribute` gets converted to a plain string, because
that's how HTML attributes work. However, this polyfil was missing this step,
and it was passing the raw non-string value to the custom element
attributeChangedCallback. This behavior is wrong, and it is a regression when
compared to not using the polyfill.

Fixes webcomponents#607, supersedes webcomponents#616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment