preactjs / preact-custom-element

Wrap your component up as a custom element
MIT License
360 stars 52 forks source link

In Firefox, The Custom Element gets cloned when calling member function of props, like toUpperCase() #50

Closed wbern closed 4 years ago

wbern commented 4 years ago

Sandbox: https://codesandbox.io/s/preact-custom-element-forked-mro87

How to reproduce

Try change the attribute value to something else.

You don't even need to render the string, just call size.toLowerCase() in an expression inside the functional component.

The issue

Workaround

Do a check if the size prop is null, and do an early return. The temporary null value is what caused the element to be cloned.

With null checking sandbox: https://codesandbox.io/s/preact-custom-element-forked-40vfr?file=/src/Button.tsx

Just try to change the size attribute as usual.