Using platform.js to get this working on Firefox - #1
Conversation
Had to make some compromises to get this to work, but it runs on Firefox 30 and Chrome 36! \o/
By using both the real document and the shimmed ownerDocument, this works again! Much closer to the original version :)
|
Update, with even more success! Using both Currently in Safari 8 nothing works - getting |
|
Thanks for the continued work on this!. What would you think about us offering up a version that works without platform.js and one that works everywhere using it? This might help those who run into similar native vs. issues further down the line. |
|
Yep that'd be the way to go I think. A single version that works with or without platform.js, so it's dependecy-free on Chrome and only one file needed for everything else :) What is document._currentScript actually doing in this case? I'm going to be converting x-gif to this style this week then talk about it as Cascadia, so I might ping you with a few more questions. |
Feature detection FTW!
|
Figured out what appears to be a minimal set of feature detects to avoid loading platform.js, and then using |
|
I have to apologize for taking forever (1 week!) to get back to you, but geelen@3e51121 is really hawt. Nice work, @geelen. Is that the only set of changes that are now required to get this puppy working? |
|
When trying with Firefox/Nightly (34.0a1 on http://mcepl.github.io/componentized-todo/) I get this error when storing TODO item: |
|
Confirmed that I'm seeing the same error as above in the latest FF Nightly builds. Investigating. |
|
Line that is likely to blame: https://github.com/addyosmani/componentized-todo/blob/gh-pages/components/todo-app/component.html#L186 |
I had to make some compromises -‼️ 😎
document.querySelector('#template')within the component definitions was returningnull. In Chrome it appears that calling the IIFE withdocument.currentScript.ownerDocumentgives you the right (isolated) context, but in Firefox w/ platform.js that is returning the maindocumentforindex.html, which doesn't have a#templateelement, and it returns null. So instead of fighting with something I didn't understand, I decided to move the templates intoindex.html, change the IIFE invocation to simplydocumentand see what happened. And it workedThis sort of stuff is really exciting to me. It was only when I realised that Polymer and Platform were different and might be able to used separately, and the pace at which native implementations have reached Chrome, that I started to think that we could do 'raw' Web Components cross-browser, now. Which I would like very much for x-gif :)
One final thought, how easy would it be to detect native support for the Web Components features in the browser and conditionally load
platform.js?Thanks for putting this example together!