Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

URL Polyfill Missing #53

Closed
erikringsmuth opened this issue Nov 14, 2014 · 7 comments
Closed

URL Polyfill Missing #53

erikringsmuth opened this issue Nov 14, 2014 · 7 comments

Comments

@erikringsmuth
Copy link

webcomponents.js seems to have dropped support for the URL() constructor function.

<!doctype html>
<html>
  <head>
    <script src="/bower_components/webcomponentsjs/webcomponents.js"></script>
  </head>
  <body>
    <script>
      var url = new URL('http://localhost:8080/test.html');
    </script>
  </body>
</html>

throws error

"Object doesn't support this action"

This worked in platform.js.

<!doctype html>
<html>
  <head>
    <script src="/bower_components/platform/platform.js"></script>
  </head>
  <body>
    <script>
      var url = new URL('http://localhost:8080/test.html');
    </script>
  </body>
</html>

platform.js referenced URL in build.json. webcomponents.js doesn't seem to reference it anywhere.

@jmesserly
Copy link
Contributor

good catch. This used to bite me as well, if I somehow didn't have the URL repository checked out and tried to build platform.js

Digging into this a bit more, my guess is that this is by design (sort of an intentional breaking change) ... it doesn't seem like the webcomponents.js polyfills use the new URL constructor. So maybe the idea was to have it be its own polyfill. OTOH, polymer-dev's build includes it now:
https://github.com/Polymer/polymer-dev/blob/master/build.json#L13

@erikringsmuth
Copy link
Author

Interesting... The new URL() constructor may not be part of the "Web Components" group of specs, but it's definitely part of the native WHATWG spec. I was using this in app-router which doesn't rely on Polymer so if it's out of webcomponents.js I may need to require it as a separate dependency or parse URLs manually. 😦

@jmesserly
Copy link
Contributor

yeah, maybe depend directly on https://github.com/Polymer/URL? does it need a file to expose it better to pkg managers? or is there something else we could do to make it easy to consume as its own pkg?

@sorvell would be the decider for whether to include in webcomponents.js ... I can definitely see the argument in favor; it means less code for custom elements on browsers that do support web components natively. And as you point out, it's really convenient to have around too.

@sorvell
Copy link
Contributor

sorvell commented Nov 15, 2014

We removed URL from webcomponents.js simply because it was not necessary. I
suggest we make an HTMLImport for it so it can more easily be included in
elements like app-router.

On Fri, Nov 14, 2014 at 4:15 PM, John Messerly [email protected]
wrote:

yeah, maybe depend directly on https://github.com/Polymer/URL? does it
need a file to expose it better to pkg managers? or is there something else
we could do to make it easy to consume as its own pkg?

@sorvell https://github.com/sorvell would be the decider for whether to
include in webcomponents.js ... I can definitely see the argument in favor;
it means less code for custom elements on browsers that do support web
components natively. And as you point out, it's really convenient to have
around too.


Reply to this email directly or view it on GitHub
#53 (comment)
.

@erikringsmuth
Copy link
Author

Actually I think I've got a good fallback if this doesn't get added back to webcomponents.js. I can use <a> tags to parse the parts of the URL I need.

var a = document.createElement('a');
a.href = url;
var path = a.pathname;
// ...

That seems to work and cover the cases I need.

@addyosmani
Copy link
Member

I think it makes sense for us to not include the URL polyfill in this package outright. We could however add a note more clearly to the readme stating that it isn't included. I should also update http://webcomponents.org/polyfills/ as to the best of my knowledge this was still being pulled in.

@sorvell could you confirm if the other two items are also still valid? (i.e are we still including WeakMap and MO shims or keeping separate?)

@sorvell
Copy link
Contributor

sorvell commented Nov 21, 2014

Yes. CustomElements/HTMLImports depend on MO which depends on WeakMap.

On Fri, Nov 21, 2014 at 6:42 AM, Addy Osmani [email protected]
wrote:

I think it makes sense for us to not include the URL polyfill in this
package outright. We could however add a note more clearly to the readme
stating that it isn't included. I should also update
http://webcomponents.org/polyfills/ as to the best of my knowledge this
was still being pulled in.

@sorvell https://github.com/sorvell could you confirm if the other two
items are also still valid? (i.e are we still including WeakMap and MO
shims or keeping separate?)


Reply to this email directly or view it on GitHub
#53 (comment)
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants