polyfills
polyfills copied to clipboard
[URL] URL polyfill isn't compatible with the spec: doesn't throw on partial URLs
Description
The URL polyfill does not throw an exception on new URL( string )
where string
is not an absolute URL and no base URL is provided.
Live Demo
https://jsbin.com/dahuqeqoyu/edit?html,console,output
Steps to Reproduce
- Ensure that the URL polyfill is active by e.g. specifying
window.forceJURL = true
before loading it - Attempt to create a URL object from a partial URL and no base, e.g.
new URL('/path')
- Observe whether an exception is thrown or not
Expected Results
It's expected that an exception is thrown if a URL string without a scheme is provided and no base is provided, as per https://url.spec.whatwg.org/#no-scheme-state (emphasis mine):
If base is null, or base’s cannot-be-a-base-URL flag is set and c is not U+0023 (#), validation error, return failure.
Modern browsers that implement the spec behave as expected.
Actual Results
An error is not thrown, and instead a URL object is created with most of its properties set to empty strings, and the protocol
property set to ":"
.
Browsers Affected
Any browser in which the polyfill is applied, whether it's because there's no native support for URL
(e.g. IE11), or because the polyfill is forced (window.forceJURL = true
).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Adding a note that the polyfill is very much still being used, so it may still be worth it to fix this issue.
Adding a note that this bug is still present in the latest version, @webcomponents/[email protected]
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@bicknellr Can I create a PR to fix this bug?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.