Search code examples
polymerpolymer-1.0web-componentcustom-element

How to handle document.registerElement deprecation in Polymer v1?


In the browser console, I see:

[Deprecation] document.registerElement is deprecated and will be removed in M73, around March 2019. Please use window.customElements.define instead. See https://www.chromestatus.com/features/4642138092470272 for more details.

It's coming from polymer-micro.html:443, which is coming from my Polymer 1.11.3 package in my project. I believe that's the latest v1 version.

How do I handle this without updating Polymer to v2? I tried updating to Polymer 2, but it's failing at runtime. I guess the api changed.


Solution

  • For polymer v1 based components to work with the latest versions of modern browsers you should add the Web Components v0 polyfills in a way similar to this in your main html

    <script src="/bower_components/webcomponentsjs/webcomponents-lite-min.js"></script>
    

    For more info on this check the polymer team's blog post