SirPepe/ornament

@connected() on private methods throws when an already-connected component initializes

SirPepe opened this issue · 0 comments

import { define,  reactive, connected} from "@sirpepe/ornament";

@define("my-greeter")
class MyGreeter extends HTMLElement {
  #value = 42;
  @connected()
  @reactive()
  #foo() {
    console.log(this.#value);
  }
}

Results in "Uncaught TypeError: Attempted to access private element on non-instance"

This may also happen with other wrappers around lifecycle callbacks, such as @formAssociated because they run into the same problem (their "event" happens before the instances are completely initialized).