You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's been brought to my attention that Svelte removes attributes on elements when it "claims" them, so a custom element that adds itself some attributes will have them removed by Svelte at some point. This would be the case for example for ARIA attributes or custom attributes added to emulate custom states for styling, pending global support for ElementInternals and CustomStateSet (e.g. using https://github.com/calebdwilliams/element-internals-polyfill).
To reproduce, paste the following code in the Svelte REPL at https://svelte.dev/repl, then inspect the rendered DOM:
<script>
let name ='world';classFooBarElementextendsHTMLElement {constructor() {super(); }connectedCallback() {this.ariaLabel="foo";this.setAttribute("state--foo", "bar"); } }customElements.define("foo-bar", FooBarElement)
</script>
<h1>Hello {name}!</h1>
<foo-bar></foo-bar>
The text was updated successfully, but these errors were encountered:
tbroyer
changed the title
Add a test that attributes added in custom element constructor aren't removed by the framework
Add a test that attributes added in custom elements aren't removed by the framework
Jan 26, 2023
It's been brought to my attention that Svelte removes attributes on elements when it "claims" them, so a custom element that adds itself some attributes will have them removed by Svelte at some point. This would be the case for example for ARIA attributes or custom attributes added to emulate custom states for styling, pending global support for
ElementInternals
andCustomStateSet
(e.g. using https://github.com/calebdwilliams/element-internals-polyfill).To reproduce, paste the following code in the Svelte REPL at https://svelte.dev/repl, then inspect the rendered DOM:
The text was updated successfully, but these errors were encountered: