Giter Site home page Giter Site logo

error ""Failed to construct 'HTMLElement': Please use the 'new' operator"" when using with Angular/elements 8.2.0 about document-register-element HOT 2 CLOSED

 avatar commented on June 20, 2024
error ""Failed to construct 'HTMLElement': Please use the 'new' operator"" when using with Angular/elements 8.2.0

from document-register-element.

Comments (2)

MikeVaz avatar MikeVaz commented on June 20, 2024

I believe the problem is how you transpile your ES2015 code in ES5 code. And it might be in NgElement code.

Transpilers VS 1.9
The version 1.9 of this polyfill does not patch browsers with full native support for Custom Elements, as anyone would expect from a polyfill based on features detection.

However, if your transpiler transforms native ES2015 classes into something incompatible, like TypeScript does in this case, you need to update, change, or better configure your tools to support proper classes.

Babel 7 should've solved this in core, so use Babel 7 if you need transpilers.

I would try to compare what is used in this angular module to deal with ES classes. Is it transpiled by Typescript or is it trying to do something custom to mimic classes. If it is a custom solution you'd probably want to fix it by applying similar pattern from Babel 7 to reflect ES classes in ES5 syntax better.

I know, it might be supper overwhelming for devs who are not JS nerds. But it is a side effect of frameworks and tools we use right now and extra unnecessary complexity we invited to our projects.

from document-register-element.

WebReflection avatar WebReflection commented on June 20, 2024

1.9 indeed doesn't care about broken transpilers do this is a won't fix.

You can use older versions from CDNs or update your transpiler or create bundles for modern browsers without transpiling classes.

from document-register-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.