webcomponentsjs icon indicating copy to clipboard operation
webcomponentsjs copied to clipboard

Firefox 35 doesn't define Element.prototype.createShadowRoot

Open pennyfx opened this issue 11 years ago • 8 comments

createShadowRoot is not defined in Firefox 35 and throws 'originalCreateShadowRoot is undefined'.

https://github.com/webcomponents/webcomponentsjs/blob/0.5.4/webcomponents-lite.js#L1365

pennyfx avatar Jan 27 '15 23:01 pennyfx

hi @pennyfx webcomponents-lite does not include ShadowDOM polyfill, and Firefox does not yet implement ShadowDOM, so this is not expected to work. Use webcomponents.js if you need createShadowRoot. let me know if that works for you. Cheers!

jmesserly avatar Jan 28 '15 00:01 jmesserly

I don't need to use it. The issue is that you guys are not checking to see if createShadowRoot is defined before calling it on line 1367.

https://github.com/webcomponents/webcomponentsjs/blob/0.5.4/webcomponents-lite.js#L1367

pennyfx avatar Jan 28 '15 00:01 pennyfx

Please check to see if Element.prototype.createShadowRoot exists before rewriting it. Otherwise downstream libraries won't be able to feature detect on it.

pennyfx avatar Jan 28 '15 00:01 pennyfx

hi, can you explain who's calling createShadowRoot? you're linking to the var root = ... line:

  var originalCreateShadowRoot = Element.prototype.createShadowRoot;
  Element.prototype.createShadowRoot = function() {
    var root = originalCreateShadowRoot.call(this);
    CustomElements.watchShadow(this);
    return root;
  };

to get there, someone had to call createShadowRoot already. who? a jsbin to illustrate the problem you're seeing would be very helpful. or at least a full stack trace. Thanks!

jmesserly avatar Jan 28 '15 15:01 jmesserly

Ah, I think I get what you're saying. Yeah, the point about feature detection is good. I was confused by Firefox 35 in the bug title, it made it sound like a much more specific problem you were hitting :)

A workaround for feature testing Shadow DOM is window.ShadowRoot.

I'm guessing the fix for this is really simple, but let me double check the ordering when we're in webcomponents.js

jmesserly avatar Jan 28 '15 15:01 jmesserly

ah, I see #174 too, going to dupe this against that one (also taking a look)

jmesserly avatar Jan 28 '15 15:01 jmesserly

fyi, landed the fix. thanks for filing this!

jmesserly avatar Jan 28 '15 16:01 jmesserly

Awesome, thanks.

-----Original Message----- From: "John Messerly" [email protected] Sent: ‎1/‎28/‎2015 8:49 AM To: "webcomponents/webcomponentsjs" [email protected] Cc: "Arron Schaar" [email protected] Subject: Re: [webcomponentsjs] Firefox 35 doesn't defineElement.prototype.createShadowRoot (#173)

fyi, landed the fix. thanks for filing this! — Reply to this email directly or view it on GitHub.=

pennyfx avatar Jan 28 '15 17:01 pennyfx