SirPepe/ornament

Decorated private class fields lead to seemingly unrelated failures in decorated private methods

SirPepe opened this issue · 1 comments

To reproduce:

@define("test-el")
class Test extends HTMLElement {
  @debounce({ fn: debounce.timeout(0) }) #a = () => {};
  @reactive() #test() {}
}
new Test();

The exception Attempted to access private element on non-instance occurs when the initializer for @reactive() performs context.access.get(this). This can be fixed once babel has been updated to support context.addInitializer in class fields, see tc39/proposal-decorators#508 (comment)

Until then, either the method or the field can't be private.

Babel now supports context.addInitializer() for class fields, but they run at the wrong time: babel/babel#16188

This remains broken for now.