5

it looks like it does not work.

Please note i am referring to custom elements v1 as mentioned here: https://developers.google.com/web/fundamentals/getting-started/primers/customelements

on my site I in the javascript console, I see

SCRIPT1002: Syntax Error, NewInvite.js Line 1, Column 1

Where the first line in NewInvite.js is

class NewInvites extends HTMLElement

Note: I am not referring to 'polymer' or 'web components'

Lastly, site runs fine on safari, mobile safari, and chrome

user1709076
  • 2,538
  • 9
  • 38
  • 59
  • Ask Microsoft? As far as I've read, they are only adding security patches to IE not new features. New features go into Edge instead. Also, did you test Firefox, Opera, Vivialdi? – Dave S Jun 23 '17 at 21:02
  • thanks, yeah i just found this. looks like edge is still voting on whether they do it or not? https://wpdev.uservoice.com/forums/257854-internet-explorer-platform/suggestions/6261318-html-imports – user1709076 Jun 23 '17 at 21:33

2 Answers2

4

If you're willing to use a few polyfills and a little extra boilerplate for each component, you can actually write v1 compatible custom elements in ES5 (without classes) that will work in IE11.

Based on this comment on github you can use regular functions to define your custom elements, and then just make sure to call Reflect.construct inside the component's constructor.

function MyEl() {
  return Reflect.construct(HTMLElement,[], this.constructor);
}

MyEl.prototype = Object.create(HTMLElement.prototype);
MyEl.prototype.constructor = MyEl;
Object.setPrototypeOf(MyEl, HTMLElement);

MyEl.prototype.connectedCallback = function() {
  console.log('my-el connected');
};
customElements.define('my-el', MyEl);
document.body.appendChild(document.createElement('my-el'));

See this post for a full working example.

TwitchBronBron
  • 2,783
  • 3
  • 21
  • 45
2

Looks like the answer is 'No' and 'Edge' which is meant to replace 'internet explorer' is still undecided, but you can vote on it here

https://wpdev.uservoice.com/forums/257854-internet-explorer-platform/suggestions/6261318-html-imports

According to Wikipedia only 10% of people use internet explorer anymore, so probably just easier to say "this site does not support Internet Explorer" instead of writing your website twice -

https://en.m.wikipedia.org/wiki/Usage_share_of_web_browsers

user1709076
  • 2,538
  • 9
  • 38
  • 59