From 4cb6328a1cc35c93e306751a0f0c610fa5c800d7 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 12 Oct 2015 13:17:03 +0200 Subject: [PATCH] Now HTML has inlined URLUtils, inline it here too This fixes #62, but #61 still needs some work. --- url.bs | 574 ++++++++++++++----------------------------------------- url.html | 574 ++++++++++++++++--------------------------------------- 2 files changed, 306 insertions(+), 842 deletions(-) diff --git a/url.bs b/url.bs index 8c6160f8..10eb9410 100644 --- a/url.bs +++ b/url.bs @@ -1140,8 +1140,7 @@ optionally with an encoding

The encoding override argument is a legacy concept only relevant for - HTML. The url and state override arguments are only for use by - objects implementing the {{URLUtils}} interface. + HTML. The url and state override arguments are only for use by various APIs. [[!HTML]]

When the url and state override arguments are not passed, the @@ -2343,25 +2342,15 @@ it.

API

-

Significant issues have been found -with the {{URLUtils}} setup, please refrain from implementing at this point in time. -

 [Constructor(USVString url, optional USVString base),
  Exposed=(Window,Worker)]
 interface URL {
   static USVString domainToASCII(USVString domain);
   static USVString domainToUnicode(USVString domain);
-};
-URL implements URLUtils;
-URL implements URLUtilsSearchParams;
 
-[NoInterfaceObject,
- Exposed=(Window,Worker)]
-interface URLUtils {
   stringifier attribute USVString href;
   readonly attribute USVString origin;
-
            attribute USVString protocol;
            attribute USVString username;
            attribute USVString password;
@@ -2370,23 +2359,11 @@ interface URLUtils {
            attribute USVString port;
            attribute USVString pathname;
            attribute USVString search;
-           attribute USVString hash;
-};
-
-[NoInterfaceObject,
- Exposed=(Window, Worker)]
-interface URLUtilsSearchParams {
   readonly attribute URLSearchParams searchParams;
+           attribute USVString hash;
 };
 
-

{{URLUtilsSearchParams/searchParams}} is on its own interface since {{Location}} cannot support -it. [[!HTML]] - -

Since all members are readonly and certain members from {{URLUtils}} are not -exposed a number of potential optimizations is possible compared to objects implementing -{{URLUtils}}. These are left as an exercise to the reader. - -

Specifications defining objects implementing {{URLUtils}}/{{URLUtilsSearchParams}} must define a -get the base algorithm, which must return the -appropriate base URL for the object. - -

Specifications defining objects implementing {{URLUtils}} may define -update steps to make it possible -for an underlying string (such as an attribute value) to -be updated. The update steps are passed a string value for -this purpose. - -

An object implementing {{URLUtils}} has an associated -input (a string or null), -query encoding (an -encoding), query object (a -{{URLSearchParams}} object or null), and a -url (a URL or null). - -Unless stated otherwise, query encoding is utf-8 and -query object is null. The others follow from the set the input -algorithm. - -

The associated -query encoding is a legacy -concept only relevant for HTML. -[[!HTML]] - -

Specifications defining objects implementing {{URLUtils}}/{{URLUtilsSearchParams}} must use the -set the input algorithms to set input, url, and -query object. To -set the input -given input and optionally a url, run these steps: - -

    -
  1. Set input to input. - -

  2. Set url to url, if url is given, - and to null otherwise. - -

  3. -

    If input is non-null, run these substeps: - -

      -
    1. Let url be the result of running the URL parser on - input with base URL being the result of running - get the base and query encoding as - encoding override. - - -

    2. If url is not failure, set url to - url. -

    - -
  4. Let query be url's query, - if url and its query are non-null, and the - empty string otherwise. - -

  5. If query object is null, set query object - to a new {{URLSearchParams}} object using query, - and then set query object's url object to - the context object. - -

  6. Otherwise, set query object's list - to the result of parsing query. -

- -

To reset the input, run these steps: - -

    -
  1. If context object is a {{URL}} object or input - is null, terminate these steps. - -

  2. Set the input using input and url. -

- -

This algorithm is necessary as get the base can return a -new result. - -

To run the pre-update steps for an object implementing {{URLUtils}}, -optionally given a value, run these steps: - -

    -
  1. If value is not given, let value be the result - of serializing the associated - url. - - -

  2. Run the update steps with value. -

+

A {{URL}} object has an associated url (a +URL) and query object (a +{{URLSearchParams}} object).

Constructors

-

The URL(url, base) -constructor, when invoked, must run these steps: +

The URL(url, base) constructor, +when invoked, must run these steps:

  1. Let parsedBase be null. @@ -2515,16 +2407,16 @@ constructor, when invoked, must run these steps:

  2. If parsedURL is failure, throw a TypeError exception. -

  3. Let result be a new {{URL}} object. +

  4. Let query be parsedURL's query, if that is non-null, + and the empty string otherwise. -

  5. Let result's get the base return parsedBase. +

  6. Let result be a new {{URL}} object. -

  7. -

    Run result's set the input given the empty string and - parsedURL. +

  8. Set result's url to parsedURL. -

    A {{URL}} object's input is never - exposed. +

  9. Set result's query object to a new + {{URLSearchParams}} object using query, and then set that query object's + url object to the context object.

  10. Return result.

@@ -2579,354 +2471,223 @@ method, when invoked, must run these steps: -

{{URLUtils}}/{{URLUtilsSearchParams}} members

- -

The {{URLUtils}}/{{URLUtilsSearchParams}} interfaces are not exposed on the global -object. They are mixins for other objects, such as {{URL}}. - -

The href -attribute's getter must run these steps: - -

    -
  1. Reset the input. - -

  2. If input is null, return the empty string. - -

  3. If url is null, return input. +

    {{URL}} members

    -
  4. Return the serialization of url. -

+

The href attribute's getter must return the +serialization of context object's url.

The href attribute's setter must run these steps:

    -
  1. Let input be the given value. - -

  2. -

    If the context object is a {{URL}} object, run these substeps: - -

      -
    1. Let parsedURL be the result of running the - basic URL parser on input - with base URL being the result of running - get the base. - -

    2. If parsedURL is failure, - throw a TypeError exception. - -

    3. -

      Run set the input given the empty - string and parsedURL. - -

      A {{URL}} object's input is - never exposed. -

    +
  3. Let parsedURL be the result of running the basic URL parser on the given + value. -

  4. -

    Otherwise, run these substeps: - -

      -
    1. Run the set the input - algorithm for input. +

    2. If parsedURL is failure, throw a TypeError exception. -

    3. Run the pre-update steps with the input. -

    - -
    -

    This means that if the href attribute is set to - value that would cause the URL parser to return - failure, that value is still passed through unchanged. This is one of those unfortunate - legacy incidents. - -

    -var a = document.createElement("a"),
    -    input = "https://test:test/" // invalid port makes the parser return failure
    -a.href = test
    -a.href === test // true
    -
    +
  5. Set context object's url to parsedURL.

-

The origin -attribute's getter must run these steps: - -

    -
  1. Reset the input. - -

  2. If url is null, return the empty string. - -

  3. Return the Unicode serialization - of url's origin. [[!HTML]] -

+

The origin attribute's getter must return the +Unicode serialization of context object's +url's origin. [[!HTML]]

It returns the Unicode rather than the ASCII serialization for compatibility with HTML's MessageEvent feature. [[!HTML]] -

The protocol -attribute's getter must run these steps: +

The protocol attribute's getter must return +context object url's scheme, followed by ":". -

    -
  1. Reset the input. +

    The protocol attribute's setter must +basic URL parse the given value, followed by ":", with +context object's url as url and scheme start state as +state override. -

  2. If url is null, return ":". +

    The username attribute's getter must return +context object's url's username. -

  3. Return scheme, followed by ":". -

- -

The protocol attribute's setter must run -these steps: +

The username attribute's setter must run these steps:

    -
  1. If url is null, terminate these steps. - -

  2. Basic URL parse the given value, followed by - ":", with url as url and - scheme start state as state override. - -

  3. Run the pre-update steps. -

- -

The username -attribute's getter must run these steps: - -

    -
  1. Reset the input. - -

  2. If url is null, return the empty string. - -

  3. Return username. -

- -

The username attribute's setter must -run these steps: - -

    -
  1. If url is null, its host is null, or its +

  2. If context object's url's host is null, or its non-relative flag is set, terminate these steps. -

  3. Set the username given url and the given value. - -

  4. Run the pre-update steps. +

  5. Set the username given context object's url and the given + value.

-

The password -attribute's getter must run these steps: +

The password attribute's getter must run these steps:

    -
  1. Reset the input. +

  2. If context object's url's password is null, return the + empty string. -

  3. If url is null or its password - is null, return the empty string. - -

  4. Return password. +

  5. Return context object's url's password.

-

The password attribute's setter must -run these steps: +

The password attribute's setter must run these steps:

    -
  1. If url is null, its host is null, or its +

  2. If context object's url's host is null, or its non-relative flag is set, terminate these steps. -

  3. Set the password given url - and the given value. - -

  4. Run the pre-update steps. +

  5. Set the password given context object's url and the given + value.

-

The host attribute's -getter must run these steps: +

The host attribute's getter must run these steps:

    -
  1. Reset the input. +

  2. Let url be context object's url. -

  3. If url is null, or its host is null, - return the empty string. +

  4. If url's host is null, return the empty string. -

  5. If port is null, return host, - serialized. +

  6. If url's port is null, return url's + host, serialized. -

  7. Return host, serialized, followed by - ":" and port, serialized. +

  8. Return url's host, serialized, + followed by ":" and url's port, + serialized.

-

The host attribute's setter must run these -steps: +

The host attribute's setter must run these steps:

    -
  1. If url is null, or its non-relative flag is set, - terminate these steps. +

  2. If context object's url's non-relative flag is set, terminate + these steps. -

  3. Basic URL parse the given value with - url as url and host state as - state override. - -

  4. Run the pre-update steps. +

  5. Basic URL parse the given value with context object's + url as url and host state as state override.

-

The hostname -attribute's getter must run these steps: +

The hostname attribute's getter must run these steps:

    -
  1. Reset the input. - -

  2. If url is null, or its host is null, - return the empty string. +

  3. If context object's url's host is null, return the + empty string. -

  4. Return host, serialized. +

  5. Return context object's url's host, + serialized.

-

The hostname attribute's setter must -run these steps: +

The hostname attribute's setter must run these steps:

    -
  1. If url is null, or its non-relative flag is set, - terminate these steps. - -

  2. Basic URL parse the given value with - url as url and hostname state as - state override. +

  3. If context object's url's non-relative flag is set, terminate + these steps. -

  4. Run the pre-update steps. +

  5. Basic URL parse the given value with context object's + url as url and hostname state as state override.

-

The port attribute's -getter must run these steps: +

The port attribute's getter must run these steps:

    -
  1. Reset the input. - -

  2. If url is null, or its port is null, return - the empty string. +

  3. If context object's url's port is null, return the + empty string. -

  4. Return port, serialized. +

  5. Return context object's url's port, + serialized.

-

The port attribute's setter must run these -steps: +

The port attribute's setter must run these steps:

    -
  1. If url is null, its host is null, - its non-relative flag is set, or its scheme is - "file", terminate these steps. - -

  2. Otherwise, Basic URL parse the given value with - url as url and port state as - state override. +

  3. If context object's url's host is null, its + non-relative flag is set, or its scheme is "file", terminate + these steps. -

  4. Run the pre-update steps. +

  5. Basic URL parse the given value with context object's + url as url and port state as state override.

-

The pathname -attribute's getter must run these steps: +

The pathname attribute's getter must run these steps:

    -
  1. Reset the input. +

  2. If context object's url's non-relative flag is set, return the + first string in context object's url's path. -

  3. If url is null, return the empty string. - -

  4. If the non-relative flag is set, return the first string in - path. - -

  5. Return "/", followed by the strings in path - (including empty strings), separated from each other by "/". +

  6. Return "/", followed by the strings in context object's + url's path (including empty strings), separated from each other by + "/".

-

The pathname attribute's setter must +

The pathname attribute's setter must run these steps:

    -
  1. If url is null, or its - non-relative flag is set, terminate these steps. +

  2. If context object's url's non-relative flag is set, terminate + these steps. -

  3. Empty path. +

  4. Empty context object's url's path. -

  5. Basic URL parse the given value with - url as url and path start state as - state override. - -

  6. Run the pre-update steps. +

  7. Basic URL parse the given value with context object's + url as url and path start state as state override.

-

The search -attribute's getter must run these steps: +

The search attribute's getter must run these steps:

    -
  1. Reset the input. - -

  2. If url is null, or its query is - either null or the empty string, return the empty string. +

  3. If context object's url's query is either null or the + empty string, return the empty string. -

  4. Return "?", followed by query. +

  5. Return "?", followed by context object's url's + query.

-

The search attribute's setter must run these +

The search attribute's setter must run these steps:

    -
  1. If url is null, terminate these steps. +

  2. Let url be context object's url. -

  3. If the given value is the empty string, set query to null, empty - query object's list, run its - update steps, and terminate these steps. +

  4. If the given value is the empty string, set url's query to null + and empty url's query object's list. -

  5. Let input be the given value with a single leading - "?" removed, if any. +

  6. Let input be the given value with a single leading "?" removed, if + any. -

  7. Set query to the empty string. +

  8. Set url's query to the empty string. -

  9. Basic URL parse input - with url as url, - query state as state override, and the - associated query encoding as - encoding override. +

  10. Basic URL parse input with url as + url and query state as state override. -

  11. Set query object's list to the - result of parsing input. - -

  12. Run query object's update steps. +

  13. Set url's query object's list to the + result of parsing input.

-

The update steps of -query object are run to ensure its -url object remains synchronized. - -

The searchParams attribute's -getter must return the query object. +

The searchParams attribute's getter must +return context object's query object. -

The hash attribute's +

The hash attribute's getter must run these steps:

    -
  1. Running reset the input is not necessary as it - cannot affect fragment. +

  2. If context object's url's fragment is either null or + the empty string, return the empty string. -

  3. If url is null, or its fragment - is either null or the empty string, return the empty string. - -

  4. Return "#", followed by fragment. +

  5. Return "#", followed by context object's url's + fragment.

-

The hash attribute's setter must run these +

The hash attribute's setter must run these steps:

    -
  1. If url is null, or its scheme is +

  2. If context object's url's scheme is "javascript", terminate these steps. -

  3. If the given value is the empty string, set fragment to - null, run the pre-update steps, and terminate these steps. - -

  4. Let input be the given value with a single leading "#" - removed, if any. +

  5. If the given value is the empty string, set context object's url's + fragment to null and terminate these steps. -

  6. Set fragment to the empty string. +

  7. Let input be the given value with a single leading "#" removed, if + any. -

  8. Basic URL parse input with - url as url and fragment state as - state override. +

  9. Set context object's url's fragment to the empty + string. -

  10. Run the pre-update steps. +

  11. Basic URL parse input with context object's + url as url and fragment state as state override.

@@ -2955,13 +2716,6 @@ which is initially empty. url object, which is initially null. -

{{URLSearchParams}} objects always use utf-8 as -encoding, despite the existence of concepts such as -query encoding. This is to -encourage developers to migrate towards -utf-8, which they really ought to -have done a long time ago now. -

To create a new {{URLSearchParams}} object, optionally using init, run these steps: @@ -2979,53 +2733,31 @@ have done a long time ago now.

  • Return query. -

    A {{URLSearchParams}} object's reset steps are these -steps: - -

      -
    1. If url object is null, return. - -

    2. Run url object's reset the input - steps. -

    -

    A {{URLSearchParams}} object's -update steps are these -steps: - -

      -
    1. Set url object's url's - query to the serialization of - {{URLSearchParams}} object's list. +update steps are to set +url object's url's query to the +serialization of {{URLSearchParams}} object's +list. -

    2. Run url object's pre-update steps. -

    - -

    The -URLSearchParams(init) -constructor, when invoked, must return a new -{{URLSearchParams}} object, using init if given. +

    The URLSearchParams(init) +constructor, when invoked, must return a new {{URLSearchParams}} object, +using init if given.

    The append(name, value) method, when invoked, must run these steps:

      -
    1. Run the reset steps. -

    2. Append a new name-value pair whose name is name and value is value, to list.

    3. Run the update steps.

    -

    The -delete(name) -method, when invoked, must run these steps: +

    The delete(name) method, when +invoked, must run these steps:

      -
    1. Run the reset steps. -

    2. Remove all name-value pairs whose name is name from list. @@ -3034,33 +2766,19 @@ method, when invoked, must run these steps:

      The get(name) -method, when invoked, must run these steps: - -

        -
      1. Run the reset steps. - -

      2. Return the value of the first name-value pair whose name is name in - list, if there is such a pair, and null otherwise. -

      +method, when invoked, must return the value of the first name-value pair whose name is +name in list, if there is such a pair, and null otherwise.

      The getAll(name) -method, when invoked, must run these steps: - -

        -
      1. Run the reset steps. - -

      2. Return the values of all name-value pairs whose name is name, in - list, in list order, and the empty sequence otherwise. -

      +method, when invoked, must return the values of all name-value pairs whose name is name, +in list, in list order, and the empty sequence otherwise.

      The set(name, value) method, when invoked, must run these steps:

        -
      1. Run the reset steps. -

      2. If there are any name-value pairs whose name is name, in list, set the value of the first such name-value pair to value and remove the others. @@ -3073,26 +2791,16 @@ method, when invoked, must run these steps:

        The has(name) -method, when invoked, must run these steps: - -

          -
        1. Run the reset steps. - -

        2. Return true if there is a name-value pair whose name is name in - list, and false otherwise. +method, when invoked, must return true if there is a name-value pair whose name is name +in list, and false otherwise.

          The value pairs to iterate over are the list name-value pairs with the key being the name and the value being the value. -

          The stringification behavior must run these steps: - -

            -
          1. Run the reset steps. - -

          2. Return the serialization of the - {{URLSearchParams}} object's list. -

          +

          The stringification behavior must return the +serialization of the {{URLSearchParams}} object's +list.

          URL APIs elsewhere

          diff --git a/url.html b/url.html index 4beacf2e..39d4aa87 100644 --- a/url.html +++ b/url.html @@ -11,7 +11,7 @@

          URL

          -

          Living Standard — Last Updated

          +

          Living Standard — Last Updated

          Participate: @@ -71,7 +71,7 @@

        3. 6.1 Constructors
        4. 6.2 URL statics -
        5. 6.3 URLUtils/URLUtilsSearchParams members +
        6. 6.3 URL members
        7. 6.4 Interface URLSearchParams
        8. 6.5 URL APIs elsewhere @@ -866,8 +866,7 @@

          encoding encoding override, optionally with an URL url and a state override state override, and then runs these steps:

          The encoding override argument is a legacy concept only relevant for - HTML. The url and state override arguments are only for use by - objects implementing the URLUtils interface. [HTML]

          + HTML. The url and state override arguments are only for use by various APIs. [HTML]

          When the url and state override arguments are not passed, the basic URL parser returns either a new URL or failure. If they are passed, the algorithm simply modifies the passed url and can terminate without returning anything.

          @@ -1680,100 +1679,31 @@

          application/x-www-form-urlencoded parsing it.

          6. API

          -

          Significant issues have been found -with the URLUtils setup, please refrain from implementing at this point in time.

          [Constructor(USVString url, optional USVString base),
            Exposed=(Window,Worker)]
           interface URL {
             static USVString domainToASCII(USVString domain);
             static USVString domainToUnicode(USVString domain);
          -};
          -URL implements URLUtils;
          -URL implements URLUtilsSearchParams;
          -
          -[NoInterfaceObject,
          - Exposed=(Window,Worker)]
          -interface URLUtils {
          -  stringifier attribute USVString href;
          -  readonly attribute USVString origin;
          -
          -           attribute USVString protocol;
          -           attribute USVString username;
          -           attribute USVString password;
          -           attribute USVString host;
          -           attribute USVString hostname;
          -           attribute USVString port;
          -           attribute USVString pathname;
          -           attribute USVString search;
          -           attribute USVString hash;
          -};
           
          -[NoInterfaceObject,
          - Exposed=(Window, Worker)]
          -interface URLUtilsSearchParams {
          -  readonly attribute URLSearchParams searchParams;
          +  stringifier attribute USVString href;
          +  readonly attribute USVString origin;
          +           attribute USVString protocol;
          +           attribute USVString username;
          +           attribute USVString password;
          +           attribute USVString host;
          +           attribute USVString hostname;
          +           attribute USVString port;
          +           attribute USVString pathname;
          +           attribute USVString search;
          +  readonly attribute URLSearchParams searchParams;
          +           attribute USVString hash;
           };
           
          -

          searchParams is on its own interface since Location cannot support -it. [HTML]

          -

          Since all members are readonly and certain members from URLUtils are not -exposed a number of potential optimizations is possible compared to objects implementing URLUtils. These are left as an exercise to the reader.

          -

          Specifications defining objects implementing URLUtils/URLUtilsSearchParams must define a get the base algorithm, which must return the -appropriate base URL for the object.

          -

          Specifications defining objects implementing URLUtils may define update steps to make it possible -for an underlying string (such as an attribute value) to -be updated. The update steps are passed a string value for -this purpose.

          -

          An object implementing URLUtils has an associated input (a string or null), query encoding (an encoding), query object (a URLSearchParams object or null), and a url (a URL or null).

          -

          Unless stated otherwise, query encoding is utf-8 and query object is null. The others follow from the set the input algorithm.

          -

          The associated query encoding is a legacy -concept only relevant for HTML. [HTML]

          -

          Specifications defining objects implementing URLUtils/URLUtilsSearchParams must use the set the input algorithms to set input, url, and query object. To set the input given input and optionally a url, run these steps:

          -
            -
          1. -

            Set input to input.

            -
          2. -

            Set url to url, if url is given, - and to null otherwise.

            -
          3. -

            If input is non-null, run these substeps:

            -
              -
            1. -

              Let url be the result of running the URL parser on input with base URL being the result of running get the base and query encoding as encoding override.

              -
            2. -

              If url is not failure, set url to url.

              -
            -
          4. -

            Let query be url’s query, - if url and its query are non-null, and the - empty string otherwise.

            -
          5. -

            If query object is null, set query object to a new URLSearchParams object using query, - and then set query object’s url object to - the context object.

            -
          6. -

            Otherwise, set query object’s list to the result of parsing query.

            -
          -

          To reset the input, run these steps:

          -
            -
          1. -

            If context object is a URL object or input is null, terminate these steps.

            -
          2. -

            Set the input using input and url.

            -
          -

          This algorithm is necessary as get the base can return a -new result.

          -

          To run the pre-update steps for an object implementing URLUtils, -optionally given a value, run these steps:

          -
            -
          1. -

            If value is not given, let value be the result - of serializing the associated url.

            -
          2. -

            Run the update steps with value.

            -
          +

          +

          A URL object has an associated url (a URL) and query object (a URLSearchParams object).

          6.1. Constructors

          -

          The URL(url, base) constructor, when invoked, must run these steps:

          +

          The URL(url, base) constructor, +when invoked, must run these steps:

          1. Let parsedBase be null.

            @@ -1789,14 +1719,15 @@

            basic URL parser on url with parsedBase.

          2. If parsedURL is failure, throw a TypeError exception.

            +
          3. +

            Let query be parsedURL’s query, if that is non-null, + and the empty string otherwise.

          4. Let result be a new URL object.

          5. -

            Let result’s get the base return parsedBase.

            +

            Set result’s url to parsedURL.

          6. -

            Run result’s set the input given the empty string and parsedURL.

            -

            A URL object’s input is never - exposed.

            +

            Set result’s query object to a new URLSearchParams object using query, and then set that query object’s url object to the context object.

          7. Return result.

          @@ -1832,282 +1763,174 @@

          domain, and unicodeDomain otherwise.

        -

        6.3. URLUtils/URLUtilsSearchParams members

        -

        The URLUtils/URLUtilsSearchParams interfaces are not exposed on the global -object. They are mixins for other objects, such as URL.

        -

        The href attribute’s getter must run these steps:

        -
          -
        1. -

          Reset the input.

          -
        2. -

          If input is null, return the empty string.

          -
        3. -

          If url is null, return input.

          -
        4. -

          Return the serialization of url.

          -
        -

        The href attribute’s -setter must run these steps:

        -
          -
        1. -

          Let input be the given value.

          -
        2. -

          If the context object is a URL object, run these substeps:

          -
            -
          1. -

            Let parsedURL be the result of running the basic URL parser on input with base URL being the result of running get the base.

            -
          2. -

            If parsedURL is failure, throw a TypeError exception.

            -
          3. -

            Run set the input given the empty - string and parsedURL.

            -

            A URL object’s input is - never exposed.

            -
          -
        3. -

          Otherwise, run these substeps:

          -
            -
          1. -

            Run the set the input algorithm for input.

            -
          2. -

            Run the pre-update steps with the input.

            -
          -
          - -

          This means that if the href attribute is set to - value that would cause the URL parser to return - failure, that value is still passed through unchanged. This is one of those unfortunate - legacy incidents.

          -
          var a = document.createElement("a"),
          -    input = "https://test:test/" // invalid port makes the parser return failure
          -a.href = test
          -a.href === test // true
          -
          -
        -

        The origin attribute’s getter must run these steps:

        +

        6.3. URL members

        +

        The href attribute’s getter must return the serialization of context object’s url.

        +

        The href attribute’s setter must run these steps:

        1. -

          Reset the input.

          +

          Let parsedURL be the result of running the basic URL parser on the given + value.

        2. -

          If url is null, return the empty string.

          +

          If parsedURL is failure, throw a TypeError exception.

        3. -

          Return the Unicode serialization of url’s origin. [HTML]

          +

          Set context object’s url to parsedURL.

        +

        The origin attribute’s getter must return the Unicode serialization of context object’s url’s origin. [HTML]

        It returns the Unicode rather than the ASCII serialization for compatibility with HTML’s MessageEvent feature. [HTML]

        -

        The protocol attribute’s getter must run these steps:

        +

        The protocol attribute’s getter must return context object url’s scheme, followed by ":".

        +

        The protocol attribute’s setter must basic URL parse the given value, followed by ":", with context object’s url as url and scheme start state as state override.

        +

        The username attribute’s getter must return context object’s url’s username.

        +

        The username attribute’s setter must run these steps:

        1. -

          Reset the input.

          -
        2. -

          If url is null, return ":".

          +

          If context object’s url’s host is null, or its non-relative flag is set, terminate these steps.

        3. -

          Return scheme, followed by ":".

          +

          Set the username given context object’s url and the given + value.

        -

        The protocol attribute’s setter must run -these steps:

        +

        The password attribute’s getter must run these steps:

        1. -

          If url is null, terminate these steps.

          -
        2. -

          Basic URL parse the given value, followed by - ":", with url as url and scheme start state as state override.

          +

          If context object’s url’s password is null, return the + empty string.

        3. -

          Run the pre-update steps.

          +

          Return context object’s url’s password.

        -

        The username attribute’s getter must run these steps:

        +

        The password attribute’s setter must run these steps:

        1. -

          Reset the input.

          +

          If context object’s url’s host is null, or its non-relative flag is set, terminate these steps.

        2. -

          If url is null, return the empty string.

          -
        3. -

          Return username.

          +

          Set the password given context object’s url and the given + value.

        -

        The username attribute’s setter must -run these steps:

        +

        The host attribute’s getter must run these steps:

        1. -

          If url is null, its host is null, or its non-relative flag is set, terminate these steps.

          -
        2. -

          Set the username given url and the given value.

          -
        3. -

          Run the pre-update steps.

          -
        -

        The password attribute’s getter must run these steps:

        -
          +

          Let url be context object’s url.

        1. -

          Reset the input.

          +

          If url’s host is null, return the empty string.

        2. -

          If url is null or its password is null, return the empty string.

          +

          If url’s port is null, return url’s host, serialized.

        3. -

          Return password.

          +

          Return url’s host, serialized, + followed by ":" and url’s port, serialized.

        -

        The password attribute’s setter must -run these steps:

        +

        The host attribute’s setter must run these steps:

        1. -

          If url is null, its host is null, or its non-relative flag is set, terminate these steps.

          -
        2. -

          Set the password given url and the given value.

          +

          If context object’s url’s non-relative flag is set, terminate + these steps.

        3. -

          Run the pre-update steps.

          +

          Basic URL parse the given value with context object’s url as url and host state as state override.

        -

        The host attribute’s -getter must run these steps:

        +

        The hostname attribute’s getter must run these steps:

        1. -

          Reset the input.

          -
        2. -

          If url is null, or its host is null, - return the empty string.

          +

          If context object’s url’s host is null, return the + empty string.

        3. -

          If port is null, return host, serialized.

          -
        4. -

          Return host, serialized, followed by - ":" and port, serialized.

          +

          Return context object’s url’s host, serialized.

        -

        The host attribute’s setter must run these -steps:

        +

        The hostname attribute’s setter must run these steps:

        1. -

          If url is null, or its non-relative flag is set, - terminate these steps.

          +

          If context object’s url’s non-relative flag is set, terminate + these steps.

        2. -

          Basic URL parse the given value with url as url and host state as state override.

          -
        3. -

          Run the pre-update steps.

          -
        -

        The hostname attribute’s getter must run these steps:

        -
          -
        1. -

          Reset the input.

          -
        2. -

          If url is null, or its host is null, - return the empty string.

          -
        3. -

          Return host, serialized.

          -
        -

        The hostname attribute’s setter must -run these steps:

        -
          -
        1. -

          If url is null, or its non-relative flag is set, - terminate these steps.

          -
        2. -

          Basic URL parse the given value with url as url and hostname state as state override.

          -
        3. -

          Run the pre-update steps.

          +

          Basic URL parse the given value with context object’s url as url and hostname state as state override.

        -

        The port attribute’s -getter must run these steps:

        +

        The port attribute’s getter must run these steps:

        1. -

          Reset the input.

          -
        2. -

          If url is null, or its port is null, return - the empty string.

          +

          If context object’s url’s port is null, return the + empty string.

        3. -

          Return port, serialized.

          +

          Return context object’s url’s port, serialized.

        -

        The port attribute’s setter must run these -steps:

        +

        The port attribute’s setter must run these steps:

        1. -

          If url is null, its host is null, - its non-relative flag is set, or its scheme is - "file", terminate these steps.

          -
        2. -

          Otherwise, Basic URL parse the given value with url as url and port state as state override.

          +

          If context object’s url’s host is null, its non-relative flag is set, or its scheme is "file", terminate + these steps.

        3. -

          Run the pre-update steps.

          +

          Basic URL parse the given value with context object’s url as url and port state as state override.

        -

        The pathname attribute’s getter must run these steps:

        +

        The pathname attribute’s getter must run these steps:

        1. -

          Reset the input.

          +

          If context object’s url’s non-relative flag is set, return the + first string in context object’s url’s path.

        2. -

          If url is null, return the empty string.

          -
        3. -

          If the non-relative flag is set, return the first string in path.

          -
        4. -

          Return "/", followed by the strings in path (including empty strings), separated from each other by "/".

          +

          Return "/", followed by the strings in context object’s url’s path (including empty strings), separated from each other by + "/".

        -

        The pathname attribute’s setter must +

        The pathname attribute’s setter must run these steps:

        1. -

          If url is null, or its non-relative flag is set, terminate these steps.

          +

          If context object’s url’s non-relative flag is set, terminate + these steps.

        2. -

          Empty path.

          +

          Empty context object’s url’s path.

        3. -

          Basic URL parse the given value with url as url and path start state as state override.

          -
        4. -

          Run the pre-update steps.

          +

          Basic URL parse the given value with context object’s url as url and path start state as state override.

        -

        The search attribute’s getter must run these steps:

        +

        The search attribute’s getter must run these steps:

        1. -

          Reset the input.

          -
        2. -

          If url is null, or its query is - either null or the empty string, return the empty string.

          +

          If context object’s url’s query is either null or the + empty string, return the empty string.

        3. -

          Return "?", followed by query.

          +

          Return "?", followed by context object’s url’s query.

        -

        The search attribute’s setter must run these +

        The search attribute’s setter must run these steps:

        1. -

          If url is null, terminate these steps.

          +

          Let url be context object’s url.

        2. -

          If the given value is the empty string, set query to null, empty query object’s list, run its update steps, and terminate these steps.

          +

          If the given value is the empty string, set url’s query to null + and empty url’s query object’s list.

        3. -

          Let input be the given value with a single leading - "?" removed, if any.

          +

          Let input be the given value with a single leading "?" removed, if + any.

        4. -

          Set query to the empty string.

          +

          Set url’s query to the empty string.

        5. -

          Basic URL parse input with url as url, query state as state override, and the - associated query encoding as encoding override.

          +

          Basic URL parse input with url as url and query state as state override.

        6. -

          Set query object’s list to the - result of parsing input.

          -
        7. -

          Run query object’s update steps.

          +

          Set url’s query object’s list to the + result of parsing input.

        -

        The update steps of query object are run to ensure its url object remains synchronized.

        -

        The searchParams attribute’s -getter must return the query object.

        -

        The hash attribute’s +

        The searchParams attribute’s getter must +return context object’s query object.

        +

        The hash attribute’s getter must run these steps:

        1. -

          Running reset the input is not necessary as it - cannot affect fragment.

          -
        2. -

          If url is null, or its fragment is either null or the empty string, return the empty string.

          +

          If context object’s url’s fragment is either null or + the empty string, return the empty string.

        3. -

          Return "#", followed by fragment.

          +

          Return "#", followed by context object’s url’s fragment.

        -

        The hash attribute’s setter must run these +

        The hash attribute’s setter must run these steps:

        1. -

          If url is null, or its scheme is +

          If context object’s url’s scheme is "javascript", terminate these steps.

        2. -

          If the given value is the empty string, set fragment to - null, run the pre-update steps, and terminate these steps.

          +

          If the given value is the empty string, set context object’s url’s fragment to null and terminate these steps.

        3. -

          Let input be the given value with a single leading "#" - removed, if any.

          +

          Let input be the given value with a single leading "#" removed, if + any.

        4. -

          Set fragment to the empty string.

          +

          Set context object’s url’s fragment to the empty + string.

        5. -

          Basic URL parse input with url as url and fragment state as state override.

          -
        6. -

          Run the pre-update steps.

          +

          Basic URL parse input with context object’s url as url and fragment state as state override.

        6.4. Interface URLSearchParams

        [Constructor(optional (USVString or URLSearchParams) init = ""),
        @@ -2127,9 +1950,6 @@ 

        A URLSearchParams object has an associated url object, which is initially null.

        -

        URLSearchParams objects always use utf-8 as encoding, despite the existence of concepts such as query encoding. This is to -encourage developers to migrate towards utf-8, which they really ought to -have done a long time ago now.

        To create a new URLSearchParams object, optionally using init, run these steps:

        1. @@ -2141,60 +1961,30 @@

          Return query.

        -

        A URLSearchParams object’s reset steps are these -steps:

        -
          -
        1. -

          If url object is null, return.

          -
        2. -

          Run url object’s reset the input steps.

          -
        -

        A URLSearchParams object’s update steps are these -steps:

        -
          -
        1. -

          Set url object’s url’s query to the serialization of URLSearchParams object’s list.

          -
        2. -

          Run url object’s pre-update steps.

          -
        -

        The URLSearchParams(init) constructor, when invoked, must return a new URLSearchParams object, using init if given.

        +

        A URLSearchParams object’s update steps are to set url object’s url’s query to the serialization of URLSearchParams object’s list.

        +

        The URLSearchParams(init) constructor, when invoked, must return a new URLSearchParams object, +using init if given.

        The append(name, value) method, when invoked, must run these steps:

          -
        1. -

          Run the reset steps.

        2. Append a new name-value pair whose name is name and value is value, to list.

        3. Run the update steps.

        -

        The delete(name) method, when invoked, must run these steps:

        +

        The delete(name) method, when +invoked, must run these steps:

          -
        1. -

          Run the reset steps.

        2. Remove all name-value pairs whose name is name from list.

        3. Run the update steps.

        -

        The get(name) method, when invoked, must run these steps:

        -
          -
        1. -

          Run the reset steps.

          -
        2. -

          Return the value of the first name-value pair whose name is name in list, if there is such a pair, and null otherwise.

          -
        -

        The getAll(name) method, when invoked, must run these steps:

        -
          -
        1. -

          Run the reset steps.

          -
        2. -

          Return the values of all name-value pairs whose name is name, in list, in list order, and the empty sequence otherwise.

          -
        +

        The get(name) method, when invoked, must return the value of the first name-value pair whose name is name in list, if there is such a pair, and null otherwise.

        +

        The getAll(name) method, when invoked, must return the values of all name-value pairs whose name is name, +in list, in list order, and the empty sequence otherwise.

        The set(name, value) method, when invoked, must run these steps:

          -
        1. -

          Run the reset steps.

        2. If there are any name-value pairs whose name is name, in list, set the value of the first such name-value pair to value and remove the others.

        3. @@ -2202,39 +1992,28 @@

          Run the update steps.

        -

        The has(name) method, when invoked, must run these steps:

        -
          -
        1. -

          Run the reset steps.

          -
        2. -

          Return true if there is a name-value pair whose name is name in list, and false otherwise.

          -

          The value pairs to iterate over are the list name-value pairs with the key being +

          The has(name) method, when invoked, must return true if there is a name-value pair whose name is name in list, and false otherwise.

          +

          The value pairs to iterate over are the list name-value pairs with the key being the name and the value being the value.

          -

          The stringification behavior must run these steps:

          -
            -
          1. -

            Run the reset steps.

            -
          2. -

            Return the serialization of the URLSearchParams object’s list.

            -
          -

          6.5. URL APIs elsewhere

          -

          A standard that exposes URLs, should expose the URL as a +

          The stringification behavior must return the serialization of the URLSearchParams object’s list.

          +

          6.5. URL APIs elsewhere

          +

          A standard that exposes URLs, should expose the URL as a string (by serializing an internal URL). A standard should not expose a URL using a URL object. URL objects are meant for URL manipulation. In IDL the USVString type should be used.

          -

          The higher-level notion here is that values are to be exposed as immutable +

          The higher-level notion here is that values are to be exposed as immutable data structures.

          -

          If a standard decides to use a variant of the name "URL" for a feature it defines, it +

          If a standard decides to use a variant of the name "URL" for a feature it defines, it should name such a feature "url" (i.e., lowercase and with an "l" at the end). Names such as "URL", "URI", and "IRI" should not be used. However, if the name is a compound, "URL" (i.e., uppercase) is preferred, e.g., "newURL" and "oldURL".

          -

          The EventSource and HashChangeEvent interfaces in HTML are examples of +

          The EventSource and HashChangeEvent interfaces in HTML are examples of proper naming. [HTML]

          -

          Acknowledgments

          -

          There have been a lot of people that have helped make URLs more interoperable over the years and +

          Acknowledgments

          +

          There have been a lot of people that have helped make URLs more interoperable over the years and thereby furthered the goals of this standard. Likewise many people have helped making this standard what it is today.

          -

          With that, many thanks to +

          With that, many thanks to 100の人, Adam Barth, Addison Phillips, @@ -2296,12 +2075,11 @@

          Ac 山岸和利 (Yamagishi Kazutoshi), and 成瀬ゆい (Yui Naruse) for being awesome!

          -

          This standard is written by Anne van Kesteren (Mozilla, annevk@annevk.nl) +

          This standard is written by Anne van Kesteren (Mozilla, annevk@annevk.nl) and Sam Ruby (IBM, rubys@intertwingly.net).

          -

          Per CC0, to +

          Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work.

          -

        Conformance

        @@ -2364,8 +2142,7 @@

        fragment state, in §4.2
      3. getAll(name), in §6.4
      4. get(name), in §6.4 -
      5. get the base, in §6 -
      6. hash, in §6.3 +
      7. hash, in §6.3
      8. has(name), in §6.4
      9. host @@ -2373,17 +2150,16 @@

        dfn for host, in §3
      10. dfn for hostsyntax, in §3.2
      11. dfn for url, in §4 -
      12. attribute for URLUtils, in §6.3 +
      13. attribute for URL, in §6.3 -
      14. hostname, in §6.3 +
      15. hostname, in §6.3
      16. hostname state, in §4.2
      17. host parser, in §3.3
      18. host serializer, in §3.4
      19. host state, in §4.2 -
      20. href, in §6.3 +
      21. href, in §6.3
      22. include credentials, in §4
      23. init, in §6.4 -
      24. input, in §6
      25. IPv4 address
      26. password
      27. path, in §4
      28. path-absolute non-Windows-file URL, in §4.1
      29. path-absolute URL, in §4.1 -
      30. pathname, in §6.3 +
      31. pathname, in §6.3
      32. path or authority state, in §4.2
      33. path-relative scheme-less URL, in §4.1
      34. path-relative URL, in §4.1 @@ -2457,27 +2233,23 @@

      35. dfn for url, in §4
      36. dfn for urlsyntax, in §4.1 -
      37. attribute for URLUtils, in §6.3 +
      38. attribute for URL, in §6.3
      39. port state, in §4.2 -
      40. pre-update steps, in §6 -
      41. protocol, in §6.3 +
      42. protocol, in §6.3
      43. query -
      44. query encoding, in §6 -
      45. query object, in §6 +
      46. query object, in §6
      47. query state, in §4.2
      48. relative slash state, in §4.2
      49. relative state, in §4.2
      50. relative URL, in §4.1
      51. relative URL with fragment, in §4.1
      52. remaining, in §1.1 -
      53. reset steps, in §6.4 -
      54. reset the input, in §6
      55. scheme @@ -2633,31 +2401,19 @@

        IDL Inde interface URL { static USVString domainToASCII(USVString domain); static USVString domainToUnicode(USVString domain); -}; -URL implements URLUtils; -URL implements URLUtilsSearchParams; - -[NoInterfaceObject, - Exposed=(Window,Worker)] -interface URLUtils { - stringifier attribute USVString href; - readonly attribute USVString origin; - - attribute USVString protocol; - attribute USVString username; - attribute USVString password; - attribute USVString host; - attribute USVString hostname; - attribute USVString port; - attribute USVString pathname; - attribute USVString search; - attribute USVString hash; -}; -[NoInterfaceObject, - Exposed=(Window, Worker)] -interface URLUtilsSearchParams { - readonly attribute URLSearchParams searchParams; + stringifier attribute USVString href; + readonly attribute USVString origin; + attribute USVString protocol; + attribute USVString username; + attribute USVString password; + attribute USVString host; + attribute USVString hostname; + attribute USVString port; + attribute USVString pathname; + attribute USVString search; + readonly attribute URLSearchParams searchParams; + attribute USVString hash; }; [Constructor(optional (USVString or URLSearchParams) init = ""),