Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element with existing shadow root is broken with Polymer 3.3.0 #5604

Open
denis-anisimov opened this issue Nov 7, 2019 · 2 comments
Open
Labels

Comments

@denis-anisimov
Copy link

denis-anisimov commented Nov 7, 2019

I have a page which loads webcomponents-loader.js , polymer 3.3.0 and this template:

import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';

class MyComponentElement extends PolymerElement {
  static get template() {
    return html`
        <button id="button">Click</button>
        <div id="content"></div>
    `;
  }

  static get is() {
    return 'my-el';
  }
}

window.MyComponentElement = MyComponentElement;

Please note that there is no customElements.define(MyComponentElement.is, MyComponentElement); line
So the element is not added out of the box to the custom elements.

Now I write the JS code in the console:

var el = document.createElement('my-el');
el.attachShadow({mode: 'open'});
document.body.appendChild(el);

The element is added as a child and there is a shadow root for it.

Now I execute:
customElements.define(window.MyComponentElement.is, window.MyComponentElement);

<my-el> shadow root is not reused and it has no expected elements there: button and div.
The shadow root is just empty.

If I add a new my-el (now when it's added to customElements ) then this added element has everything needed: its shadow root is not empty.

The same scenario works fine with Polymer 3.2.0.

@web-padawan
Copy link
Contributor

This is most likely related to the problem described in #5574 (also introduced in 3.3.0).
And the actual regression might be this one: #5574 (comment)

@sorvell could you investigate what would be a proper fix?

@stale
Copy link

stale bot commented Nov 7, 2020

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 stale bot added the wontfix label Nov 7, 2020
aarongable pushed a commit to chromium/chromium that referenced this issue Oct 19, 2022
Fixing a known Polymer regression, happening since v3.3.0, reported
at [1] and [2], using the workaround at [3]. Eventually [3] should be
upstream to the Polymer repo itself.

The regression manifested as a blank UI in chrome://history/journeys.

[1] Polymer/polymer#5604
[2] Polymer/polymer#5574
[3] Polymer/polymer#5574 (comment)

Fixed: 1376531
Change-Id: Iae15aa3d0dedac3619ee899db92101388e264149
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3964718
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1061274}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants