Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to use Polymer 2 elements in Polymer 3 element?

How can I use Polymer 2 elements in Polymer 3 element? The following doesn't work since <link> element doesn't work inside shadow dom.

static get template() {
    return '
        <link rel="import" href="...">
        <my-element></my-element>';
}

We can simply take out <link> outside of the element and put at the top level, but that feels like breaking component-ness.

like image 606
Kibeom Kim Avatar asked Jan 04 '18 22:01

Kibeom Kim


1 Answers

You can't load two version of Polymer (Polymer 2/1 and Polymer 3) because Polymer register some custom-elements to the api of webcomponents and when you try to load a component from Polymer 2 and another of Polymer 3 it tells you that you can't register x custom-element again.

But you can use LitElement and a component from Polymer 2/1, you just have to use html-import-js inside your LitElement component.

like image 99
Iván Gómez Avatar answered Oct 01 '22 10:10

Iván Gómez