Git Product home page Git Product logo

Comments (6)

TimvdLippe avatar TimvdLippe commented on July 26, 2024

You definitely can, as Polymer 2/3 elements and LitElement are all based on webcomponents. For example, this JSBin (http://jsbin.com/pokuwururi/edit?html,output) works in Firefox 60 and Chrome using both a Polymer 2 element as well as the LitElement example. (network could be a bit slow, just because it does a lot of network requests)

However, you are then responsible for doing the integration yourself, meaning you have to take care of the HTML imports and ES modules orchestration. Therefore, we advise you to use Polymer 3 and LitElement together, as they are both based on the same loading mechanism ES modules.

from lit-element.

LarsDenBakker avatar LarsDenBakker commented on July 26, 2024

@TimvdLippe That's an interesting snippet, thanks for posting that!

The only issue with this I can think of here is duplicate element definitions. For instance both Polymer 2 and 3 will try to register dom-if, dom-repeat etc. right?

from lit-element.

TimvdLippe avatar TimvdLippe commented on July 26, 2024

from lit-element.

vlaraort avatar vlaraort commented on July 26, 2024

Yes, @TimvdLippe is right, but I still have a problem. This snippet works great but is still a html file, previously in a JS file, I could do this:

    import {LitElement, html} from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
    import { importHref } from '@polymer/polymer/lib/utils/import-href';

importHref( 'https://polygit.org/polymer+:2.x/paper-checkbox+polymerelements+:master/components/paper-checkbox/paper-checkbox.html', null, null, true);
    class MyElement extends LitElement {

      static get properties() { return { mood: String }}

      _render({mood}) {
        return html`<style> .mood { color: green; } </style>
          Web Components are <span class="mood">${mood}</span>!
          <paper-checkbox></paper-checkbox>`;
      }
    }

    customElements.define('my-element', MyElement);

But now this function is removed, is there a clean solution? or should I replicate the previous importHref polymer function?

from lit-element.

TimvdLippe avatar TimvdLippe commented on July 26, 2024

from lit-element.

vlaraort avatar vlaraort commented on July 26, 2024

ok, thanks!

from lit-element.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.