Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

Add statics from builtin as needed #4

Closed
arv opened this issue Jul 24, 2014 · 5 comments · Fixed by #5
Closed

Add statics from builtin as needed #4

arv opened this issue Jul 24, 2014 · 5 comments · Fixed by #5
Assignees

Comments

@arv
Copy link

arv commented Jul 24, 2014

The builtin URL sometimes has some statics on it:

http://dev.w3.org/2006/webapi/FileAPI/#URL-object

We need to add those in case there is a webkitURL and msURL etc.

@arv arv added the bug label Jul 24, 2014
@arv arv self-assigned this Jul 24, 2014
@eligrey
Copy link

eligrey commented Jul 24, 2014

Wouldn't exactly say sometimes. Every single current release of every major browser supports the API. Also, if by "add those" you mean save references to the methods and put them on a new URL object, that is not going to work either, as URL is also used as a native function for URL parsing. (new URL(url_here).origin etc.)

Simply put, URL is a global variable that should not ever be redefined unless you're polyfilling it, as I do in Blob.js. Whatever Polymer needs it for, it can use a differently named global variable if it's not using it for the sole purpose of polyfilling it.

@arv
Copy link
Author

arv commented Jul 24, 2014

You are right, all browsers we care about have URL.createObjectURL and URL.revokeObjectURL.

We already feature detect and keep the original URL if it can be new'ed.

The PR makes sure that we add the statics if the builtin is not newable.

@eligrey
Copy link

eligrey commented Jul 24, 2014

Oh, so Polymer uses URL for it's URL processing abilities. Do you realize that document.createElement("a").href = url is an equivalent superset of new URL(url)?

See my new URL(...) polyfill for more information. You will notice that origin is manually handled, as some very old browsers don't support that natively.

@arv
Copy link
Author

arv commented Jul 24, 2014

@eligrey That is mostly correct. There are some issues with it. And it is also slower, since it needs a new document and uses <base>. I took the <a> approach in arv/DOM-URL-Polyfill but we decided to go down the current route and base this on the reference implementation of the spec.

@eligrey
Copy link

eligrey commented Jul 24, 2014

Ah, thanks for linking me to that. I wasn't aware of that polyfill, mostly as mine focuses on the blob aspects.

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

Successfully merging a pull request may close this issue.

2 participants