Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.04k stars 2.01k forks source link

Behaviors may not run `registered` if legacy element is subclassed #5567

Closed dfreedm closed 2 years ago

dfreedm commented 5 years ago

Root cause of https://github.com/PolymerElements/iron-a11y-keys-behavior/issues/93

In this scenario:

<script type="module">
  import {Polymer} from '@polymer/polymer/polymer-legacy.js';
  const behavior = {
    registered() {
      this.fizz = {};
    }
  };
  Polymer({
    is: 'x-foo',
    behaviors: [behavior]
  });

  class XBar extends customElements.get('x-foo') {}
  customElements.define(XBar.is, XBar);
</script>

<x-bar></x-bar>

<script>
  addEventListener('load', () => {
    const el = document.createElement('x-foo');
    document.body.appendChild(el);
  })
</script>

x-bar will have registered called on it, and x-foo will not. This means that fizz will only be set on x-bar, and not on x-foo's class, which is causing the error in iron-a11y-keys-behavior.

dfreedm commented 5 years ago

This is caused by moving behavior processing to be more like 1.x, which happened in 3.2.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!