Netflix / x-element

A dead simple starting point for custom elements.
Apache License 2.0
28 stars 12 forks source link

Property definition "initial" value is unexpectedly reused across instances #89

Closed klebba closed 3 years ago

klebba commented 3 years ago

For example, given an element x-baz with property block as follows:

static get properties() {
  return {
    bar: {
        type: Foo,
        initial: () => new Foo(),
    },
  };
}

Newly created instances of <x-baz> will reuse the same instance of Foo. In my case this creates an issue when attempting to destroy unwanted copies of x-baz. Because the reference is shared, any newly created <x-baz> will point to the original Foo

Happy to create a repro case if it helps

theengineear commented 3 years ago

Seems reasonable. I'll update.