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
Uncaught DOMException: Failed to construct 'CustomElement': The result must not have attributes
This is because this.ariaLabel = 'foo' in the constructor ends up triggering the attribute aria-label to be set. (Note this applies with or without the LWC ARIA reflection polyfill, at least in browsers that support ARIA reflection like Chrome and Safari.)
I experimented with removing the class field transformation a while back and one of the major issues I ran into was around reactive fields.
For context, standard class fields are properties defined on the class instance. However, Babel's class fields transformation in loose mode generates properties assignments. The key difference is that property definitions never invoke the reactivity getters/setters assigned to the class prototype. Which is problematic for reactivity.
classReactiveExample{
#foo;getfoo(){console.log('getter');returnthis.#foo;}setfoo(v){console.log('setter',v);this.#foo=v;}}classStandardextendsReactiveExample{foo='standard';}classLooseextendsReactiveExample{constructor(){super();this.foo='loose';}}newStandard();// Prints nothing!newLoose();// Prints "setter loose"
I don't think it's impossible to make it work, but it would force us to change how we handle reactivity today.
Currently the LWC compiler converts
into
This breaks some scenarios since it's not exactly the same thing, even though the syntax is similar.
This would be an observable change.
lwc/packages/@lwc/compiler/src/transformers/javascript.ts
Line 45 in 4b8b03e
The text was updated successfully, but these errors were encountered: