1

I'm testing if google polymer works on ie9. An error occurs at line 11 of webcomponents.min.js expecting ":" between get() and href. Here is the excerpt from the webcomponent.js file:

...
jURL.prototype = {
    toString: function() {
      return this.href;
    },
    get href() {
      if (this._isInvalid) return this._url;
      var authority = "";
      if ("" != this._username || null != this._password) {
        authority = this._username + (null != this._password ? ":" + this._password : "") + "@";
      }
      return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment;
    }, ....

Is there workaround to avoid this error?

Nazerke
  • 2,098
  • 7
  • 37
  • 57
  • And your question is? – Tomalak Jun 17 '15 at 03:59
  • Is there workaround to avoid this error? – Nazerke Jun 17 '15 at 04:09
  • Well, fixing the syntax error would be a good start, I guess. :) – Tomalak Jun 17 '15 at 04:53
  • webcomponents.js is part of library, it's not my file. Also, the problem is that ie 9 can't parse, not that the code is faulty. As you can see from the code there is nothing to fix – Nazerke Jun 17 '15 at 04:57
  • 1
    Of course there is. `get href() { ... }` is not valid JavaScript. It's an [ES6 getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get), the closest approximation IE9 would understand is `href: function () { ... }`. If you want to use this script in IE (or any current browser, really), you must translate it into a form without ES6 features. – Tomalak Jun 17 '15 at 05:03
  • 1
    You might try an ES6 transpiler like [babel.js](https://babeljs.io/repl/) that can automatically create source code an older JS implementation can understand. You could even make this step part of your build process. But chances are that the script doesn't work even if it can be parsed by IE9 because IE9 does not have the DOM features it relies on. – Tomalak Jun 19 '15 at 06:57

1 Answers1

1

Probably not. From their documentation

Our polyfills are intended to work in the latest versions of evergreen browsers.

Here is browser support matrix for webcomponenets.js

Support matrix https://github.com/WebComponents/webcomponentsjs#browser-support

Alex Kolarski
  • 3,255
  • 1
  • 25
  • 35