Troubleshooting: Angular Custom Elements malfunction on Firefox, Microsoft Edge, and Internet Explorer

Experimented with the Angular Elements Demo

After downloading, installing, and building the demo locally.

Implemented the following code:

<!doctype html>
<html lang="en>
<head>
  <meta charset="utf-8>
  <title>Angular Elements Demo</title>
</head>
<body>

  <hello-world name="Anna"></hello-world>

  <script src="dist/main.js"></script>
  <script>
      const helloCp = document.querySelector('hello-world');
      helloCp.addEventListener('hi', (data) => {
          console.log(data.detail);
      });
      setTimeout(() => {
        helloCp.setAttribute('name', 'Marc');
      }, 1000);
  </script>

</body>
</html>

Encountered an error while testing on Mozilla Firefox:

"ReferenceError: customElements is not defined"

However, the demo worked perfectly on Google Chrome.

Tried various Javascript polyfills as suggested online but none were successful.

The demo also failed to run on Microsoft Edge and Internet Explorer.

Is there a way to make it work on Firefox without changing its default settings?

Such as accessing about:config in Firefox.

dom.webcomponents.customelements.enabled: true dom.webcomponents.shadowdom.enabled: true

Attempted to add this Javascript file:
https://github.com/webcomponents/webcomponentsjs/blob/v1/webcomponents-lite.js

As recommended on:

Unfortunately, still no success. Any suggestions for resolving this issue?

Your assistance is greatly appreciated!

Answer №1

After some modifications, my Custom Elements project successfully ran on different browsers when I removed the

encapsulation: ViewEncapsulation.Native
setting.

Answer №2

Web Platform custom elements are currently compatible with Chrome, Opera, and Safari, with the option to use polyfills for other browsers (refer to Browser Support).

Therefore, it is recommended to include polyfills when working with Firefox, Edge...

Custom elements browser support details

Important: Custom elements work seamlessly in Chrome and Opera by default. Firefox support is nearing completion; you can enable it by adjusting preferences like dom.webcomponents.enabled and dom.webcomponents.customelements.enabled to true. Firefox's official implementation will go live in version 60/61. Meanwhile, Safari only backs autonomous custom elements, and Edge is also progressing towards an implementation.

Explore Official Documentation Here.

Answer №3

Unfortunately, Angular custom elements do not offer support for Internet Explorer. However, there is a clever workaround available to customize your Angular 4+ application's Bootstrap and ensure compatibility with IE.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular: efficient exchange of information among components

I have a component X that handles a WebSocket. And within component X, I also have multiple presentation components (e.g. Y). Whenever the WebSocket receives a specific message, I need to perform an action in a particular component (e.g. refresh data). To ...

What is preventing the bundling of my CSS into the application?

I'm facing an issue while setting up a new project using vue.js, scss, and webpack (with express.js on the server side and TypeScript). I copied over the configurations from a previous project where everything was working fine. According to my underst ...

Using perl ajax to modify a table

In my current Perl script, I am working on a functionality where I retrieve data from an xls file and display it as input text on a webpage. The objective is that when a user selects the edit option from a menu, the entire table fetched from the xls file w ...

Determine whether the ng bootstrap modal has already been opened

Is there a way to determine if a modal window is open? In order to accomplish this, I create a variable called modalInstance: NgbModalRef; and initialize the modal by using the code below this.modalInstance = this.modalService.open(UpdateModalConten ...

Is it possible to configure the Eclipse Javascript formatter to comply with JSLint standards?

I'm having trouble setting up the Eclipse Javascript formatting options to avoid generating markup that JSLint complains about, particularly with whitespace settings when the "tolerate sloppy whitespace" option is not enabled on JSLint. Is it possible ...

What is the best way to retrieve unique column values using the LoopBack REST API?

I am working with a loopback REST API that fetches data from a MySQL table and returns it in JSON format. However, I need to apply a filter or query so that only distinct values for a specific column are returned. In SQL, we use the syntax SELECT DISTINC ...

Unable to stop at breakpoints using Visual Studio Code while starting with nodemon

VSCode Version: 1.10.2 OS Version: Windows 7 Profesionnal, SP1 Node version: 6.10.0 Hey there. I'm attempting to debug TypeScript or JavaScript code on the server-side using Visual Studio Code with nodemon. I've set up a new configuration in la ...

Unable to transfer a value from a CGI script back to an HTML form

When working with an HTML form that has a date field named cdt, I encountered the need to retain the date value when submitting data to an Oracle table through a CGI script. To achieve this, instead of using Javascript code like history.go(-1), I aimed to ...

Storing multiple fields using LocalStorage in Angular2

After finding inspiration from the example at https://github.com/PillowPillow/ng2-webstorage, I successfully managed to store and retrieve the boundValue. Now, I encounter a new challenge with a list of bots: bot.component.html <tr *ngFor="let bot of ...

The dropdown menu is not appearing in the correct position when clicked

https://i.stack.imgur.com/fMyZQ.jpg Hello there, this link appears normal before clicking on it. But once clicked, it moves to the top of the page like so: https://i.stack.imgur.com/yZ0R0.jpg You can clearly see the difference. I have also provided the c ...

Tips for moving a texture horizontally across a sphere using threejs

I have a 360 degree viewer tool. Is there a way to load a texture in a specific position that will rotate the original image by a certain number of degrees or units around the Y-axis without altering anything else about how the picture is displayed? If s ...

Display a thumbnail image using a v-for loop

Looking for help with implementing a photo preview in my code using BootstrapVue. The Vue devtools show that the form-file contains the image, but my 'watch' isn't functioning properly. Any assistance would be greatly appreciated! Here is ...

AngularJS has encountered an issue with a route resolve promise that has not been completely resolved

I'm currently working on a simple task to manage user roles within routes. The goal is straightforward: Verify the role of the logged-in user on each route (using a resolve function to authenticate the user based on token or login credentials) Direc ...

Adjusting the image placement within a modal window (using bootstrap 3)

Behold, an example modal: <!-- Large Modal --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

Working towards ensuring my website is responsive

Hello, I am a CSS beginner currently working as an intern. My task is to make a website's CSS compatible with Internet Explorer, and then make it responsive and scalable. Essentially, the design should retain its appearance when the window size change ...

Updating several inputs programmatically in VueJSLet's explore how to

I am working on a form that requires updating multiple other fields when one field is updated. For instance, I have a contact name field and depending on the name entered, I need to update the email and phone number fields as well. <template> < ...

Error: In Angular Firebase, the type 'string' cannot be assigned to the type 'Date'

I am encountering an error. The following error is shown: "cannot read property 'toDate' of undefined. Without the toDate() | Date." After further investigation, I found: A Timestamp object with seconds=1545109200 and nanoseconds=0. A hel ...

Efficiently utilizing ngrx by orchestrating various services and actions to achieve accurate mapping

Combining multiple effects into one is my current goal due to an issue with dispatching actions separately. The aim is to execute sequentially after verifying the value returned from the first service call. Here are the three separate effects I have: @Eff ...

Calculating variables in JavaScript

Explanation from Mozilla Documentation: console.log((function(...args) {}).length); // The result is 0 because the rest parameter is not counted console.log((function(a, b = 1, c) {}).length); // The result is 1 because only parameters before th ...

Following an Angular update, the npm installation process encounters issues due to conflicts related to peer dependencies

I am facing challenges with updating my Angular version. When I try to use the command ng update, the output I receive is as follows: Name Version Command to update ------------------------------ ...