-
Notifications
You must be signed in to change notification settings - Fork 23
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
Remove JavaScript realm dependency #219
Remove JavaScript realm dependency #219
Conversation
To allow the algorithms in the specification to be used outside of JavaScript, we need to remove dependency to JavaScript realm. This CL make a URLPattern object associated with an underlying URL Pattern struct, and makes algorithms to use it instead. Fixes whatwg#217
@jeremyroman @sisidovski @domenic Can I ask you to take a look? |
- Run -> run - renamed |this| to |urlPattern|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove JavaScript realm, you also have to update 4.1. Integrating with JavaScript APIs not to accept realm and build URL Pattern with create?
Yes. I tried to update them to eliminate realm dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the review, @sisidovski. @jeremyroman @domenic Will you take a look? |
- The URLPattern class -> "URL patterns" - Introduce an "Introduction" subsection to contain the introductory text and examples - Introduce a "The URLPattern class" subsection to contain the IDL and method definitions - Introduce "The URL pattern struct" subsection to contain the struct definition - Introduce "High-level operations" to contain "create", "match", "has regexp groups" - Everything else can continue living in "Internals" and "Constructor string parsing" - Rename "Patterns" to "Pattern strings" to be slightly less confusing as a sibling of "URL patterns"
@domenic Thanks for the review. I have addressed your comments. |
@@ -1973,23 +1983,22 @@ JavaScript APIs should accept all of: | |||
To accomplish this, specifications should accept {{URLPatternCompatible}} as an argument to an [=operation=] or [=dictionary member=], and process it using the following algorithm, using the appropriate [=environment settings object=]'s [=environment settings object/API base URL=] or equivalent. | |||
|
|||
<div algorithm> | |||
To <dfn export>build a {{URLPattern}} from a Web IDL value</dfn> {{URLPatternCompatible}} |input| given [=/URL=] |baseURL| and [=ECMAScript/realm=] |realm|, perform the following steps: | |||
To <dfn export>build a [=URL pattern=] from a Web IDL value</dfn> {{URLPatternCompatible}} |input| given [=/URL=] |baseURL|, perform the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is a semantic change in the case where a URLPattern
is provided -- it creates a second platform object wrapping the same URL pattern, rather than returning the existing one. If it were then exposed back to script (e.g., as the value of an attribute) it would no longer compare equal (===
), its expandos would be visibly different, etc.
For the case where the author really does want a platform object because they might show it to script again, do we need to keep this? Should we have two versions of this algorithm, one which returns platform objects (and therefore takes a realm in case it needs to create them) and one which returns URL patterns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Do we know who the callers would be? I'm not sure the "returns a platform object" version would have any callers, currently.
But if we did have such a caller, then I agree a separate algorithm would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the SW static routing API usage, we actually do not provide the way to see data from JavaScript.
However, I do not have a good reason to block such use case from other APIs.
I tried to implement the algorithm with |realm| in addition.
Co-authored-by: Jeremy Roman <[email protected]>
Co-authored-by: Jeremy Roman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really nice; great work.
@@ -1973,23 +1983,22 @@ JavaScript APIs should accept all of: | |||
To accomplish this, specifications should accept {{URLPatternCompatible}} as an argument to an [=operation=] or [=dictionary member=], and process it using the following algorithm, using the appropriate [=environment settings object=]'s [=environment settings object/API base URL=] or equivalent. | |||
|
|||
<div algorithm> | |||
To <dfn export>build a {{URLPattern}} from a Web IDL value</dfn> {{URLPatternCompatible}} |input| given [=/URL=] |baseURL| and [=ECMAScript/realm=] |realm|, perform the following steps: | |||
To <dfn export>build a [=URL pattern=] from a Web IDL value</dfn> {{URLPatternCompatible}} |input| given [=/URL=] |baseURL|, perform the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Do we know who the callers would be? I'm not sure the "returns a platform object" version would have any callers, currently.
But if we did have such a caller, then I agree a separate algorithm would be best.
Also, fixed the way to call [=create=] because it won't take |pattern| any more.
I changed like so by mistake. In this context, we would want to say that it is not relevant to create a URLPattern object as a JSON input. We need to say that because unlike JavaScript API, JSON API cannot take a URLPattern object itself, which has URLPatternOptions.
To allow the API to compare values in the API's attribute with '===', the way to use |realm| has been introduced.
Co-authored-by: Jeremy Roman <[email protected]>
Thanks @jeremyroman for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
Co-authored-by: Domenic Denicola <[email protected]>
@domenic Thank you for the review! Will somebody merge this PR? |
* Fix linking to URL Pattern spec after whatwg/urlpattern#219. * Fix ambiguous "credentials" link by defaulting it to Fetch. * Fix RFC 2119 compliance in a note.
Editorial: Various minor fixes * Fix linking to URL Pattern spec after whatwg/urlpattern#219. * Fix ambiguous "credentials" link by defaulting it to Fetch. * Fix RFC 2119 compliance in a note. Fixes #300.
To allow the algorithms in the specification to be used outside of JavaScript, we need to remove dependency to JavaScript realm.
This CL make a URLPattern object associated with an underlying URL Pattern struct, and makes algorithms to use it instead.
Fixes #217
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff