简体   繁体   中英

Polymer webcomponents cross-browser compatibility

I'm having frequent problems when using Google Polymer with non-Chrome browsers (Firefox/IE). Using Polymer on its own (such as viewing Polymer Element demo pages) does not seem to cause any issues. However, issues arise when using webcomponents.js is included on an existing web-application with many included GUI and utility packages (jQueryUI,

The issue seems to be related to webcomponents.js specifically. If no HTML imports are used and only webcomponents.js is imported, it throws the same error in both Firefox and IE:

webcomponents.js:2114 - SyntaxError: An invalid or illegal string was specified
webcomponents.js:113 - Error: Assertion failed

The specific line of webcomponents.js simply reads:

list = originalDocumentQuerySelectorAll.call(target, selector);

- which seems to have no immediately obvious syntax error.

Due to this error, other GUI elements on the page now exhibit erroneous behavior. There is no other useful console output provided when this happens, and no exceptions thrown by other JS packages. None of this behavior is shown when using Chrome.

I had the same error. I solved it, loading webcomponents.js before jquery.js.

I've tested with the last version of webcomponents.js in the last version of Firefox, simply loading it (no other import used) and it seems to work...

Test here

Plunker here

Did you tried with the last version of webcomponents.js or it was an old one? How about the version of Firefox?

Couldn't test on IE, I'm on linux, sorry.

I had the same problem when loading jQuery(v1.10.2) and polymer(webcomponents.js).

Fixed it using jQuery v2.1.4.

我能够通过从脚本中删除$(document).ready来解决这个问题。

Not quite sure if this is still relevant but I bumped into this recently while running the unit tests using web-component-tester for a Polymer 1.11 based application. This issue start appearing on chrome v81 and was working fine before.

So, in each of the spec file we have an import for webcomponents.min.js which I replaced with webcomponents-lite.min.js and that worked for me.

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