-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for WHATWG URL API #10232
Support for WHATWG URL API #10232
Comments
Hello. You should be able to add your own polyfills. |
I'm aware that we could locally polyfill this (see considerations) within our app, but since this is a supported API across all common JavaScript implementations (see provided link) I think it would benefit NativeScript to provide the polyfill. My reason for saying this is: as more pure JS libraries start to use this API those libraries will be unusable within a NativeScript app without people patching webpack (or their apps) with their own polyfills. The provided library would not be a good fit for NativeScript since it uses the DOM to fill the gap to create a "valid" href link: see https://github.com/lifaon74/url-polyfill/blob/master/url-polyfill.js#L297 The polyfill mentioned within the referenced Mozilla Developer Docs would likely be a better fit: core-js |
@rigor789 How does the NativeScript team feel about polyfilling something like this in core? Would they be open to a PR? Or is the recommended course for the end user to polyfill it themselves when needed? |
@prestopasto I'm for it personally, but we'll need to discuss on the next TSC meeting. Perhaps a good initial step would be to do the polyfill in a plugin that uses the webpack plugin api to automatically set things up (https://docs.nativescript.org/webpack.html#plugin-api) and if it's something we all agree should be in core, we'll have a clear path from the plugin to core. |
@rigor789 Thank you for the feedback and direction! I'm hoping to get some time to play with it soon. |
@prestopasto one thing we're discussing as well is doing the URL parsing the same way Node does (as of recently) using Ada in c++ and possibly provide it in the runtime itself instead of core. |
Personally I would not want that enabled by default. URL polyfills are pretty big and not that commonly use. Think an opt in option in our webpack setup would be best |
Recent nativescript (version Could we please either get it fixed or get rid of it? |
@ray007 please open a new issue with an example, newer versions use ada for Closing this one, as it's now shipped with the NativeScript runtimes: |
My own polyfill works fine (and is not that large), so I'll just overwrite the native object. |
@ray007 I'm the author of Ada URL parser. Can you share a reproducible bug report? I'm more than happy to investigate. |
I already mentioned 2 cases in my description, which should be very simple to verify:
|
Thanks for test cases, we'll make sure these work as expected. |
@ray007 I fixed both of the issues, we'll have these in a release soon, thanks for pointing them out. |
Is your feature request related to a problem? Please describe.
The URL API/constructor is not currently supported in core NativeScript.
Describe the solution you'd like
Include a polyfill in NativeScript core so that it would be possible to make use of this standardized API: see https://developer.mozilla.org/en-US/docs/Web/API/URL/URL for reference
Describe alternatives you've considered
Apply a local polyfill.
Anything else?
Currently the following runtime error is encountered when attempting to use the URL constructor:
const url = new URL("https://nativescript.org"); //ReferenceError: URL is not defined
Please accept these terms
The text was updated successfully, but these errors were encountered: