简体   繁体   中英

Multiple web components in same page giving error in chrome like cannot read properties of undefined (reading create) in Angular

Created two web components: web-comp-1, web-comp-2

When I tried to add in HTML page, I am getting console error like below

Uncaught TypeError: Cannot read properties of undefined (reading 'create')
at new m.<computed> (web-comp-1.js:3:2706)
at new t (web-comp-1.js:3:12616)

When I checked the line, the code is,

(o = (u = F && 1 === a.create.length)? Reflect.construct

Generated web component using below versions and angular elements: "@angular/animations": "14.2.7", "@angular/cdk": "14.2.5", "@angular/common": "14.2.7", "@angular/compiler": "14.2.7", "@angular/core": "14.2.7", "@angular/elements": "14.2.7",

Stackblitz link:https://stackblitz.com/edit/web-platform-bkqbag?file=index.html

If you run in stack blitz, you wont see any error, you need to download the project and open in only "Chrome". This issue happening only in chrome, not in mozilla

在此处输入图像描述

Upgraded document-register-element package from 1.7.2 to 1.14.10 in package json, the error gone away. Thank you @Abolfazl Almas, your link triggered me an idea

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM