Closed trusktr closed 3 months ago
Can you please provide a minimal reproduction? It's much easier to help you if you cut everything down to the bare minimum.
If you're defining a custom element, do it in the reproduction please. Don't import libs from elsewhere if avoidable.
Sure, here's a simplified example (updated OP). Basically same steps. I added console.assert
s with descriptions inside the useEffect
. Thanks for looking!
https://stackblitz.com/edit/create-preact-starter-ydvaru?file=src%2Findex.jsx
This is working as intended.
mount-point
and mountPoint
are not the same thing; we don't try to coerce/guess prop names. If the label cannot be found on the DOM element, we set it as an attribute. You need to use <custom-element mountPoint={...}></custom-element>
.
If you wanted to contribute a note on casing/naming, you could do so here
Ah, I see. Thanks! Yeah that note will be useful.
What are your thoughts on the wording here in this PR:
Describe the bug
Preact docs say the following:
However, I have Custom Elements with setters and Preact calls
setAttribute
instead of setting the JS properties as described.To Reproduce
https://stackblitz.com/edit/create-preact-starter-ydvaru?file=src%2Findex.jsx
In this example, the
console.assert
s statements in theuseEffect
show that the JS property setter exists but that the attribute still gets set instead of the JS property.The
debugger
statement ingetMountPoint
: it will pause ontoString
of the value passed intomount-point={}
. When the devtools debugger is paused, we can see that the value gets passed intosetAttribute
.Expected behavior
We expect the value to be passed to the JS property because the setter exists, as described in the Preact documentation.