<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26930</bug_id>
          
          <creation_ts>2014-09-29 15:25:48 +0000</creation_ts>
          <short_desc>Some correct around URLSearchParams</short_desc>
          <delta_ts>2014-10-02 14:09:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>URL</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Arkadiusz Michalski (Spirit)">crimsteam</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
          
          <qa_contact>sideshowbarker+urlspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112386</commentid>
    <comment_count>0</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-09-29 15:25:48 +0000</bug_when>
    <thetext>Hi, I report a few more things that can be improved/correct:

===

In algo &quot;new URLSearchParams object&quot;:

3. If init is a string, set query&apos;s associated list of name-value pairs to the result of parsing input. &lt;&lt; not &quot;parsing input&quot; but &quot;parsing init&quot;.

===

For all URLSearchParams&apos;s method algo should be more precise, look one example for remove():
1. Remove all name-value pairs whose name is name. &lt;&lt; we don&apos;t know what is pairs, where pairs belong to.

Maybe you should make term (with ID) for asociated list in:
&quot;A URLSearchParams object has an associated list of name-value pairs called list n-v, which is initially empty.&quot;

and write this:
1. Remove all name-value pairs from list n-v of context object whose name is name. &lt;&lt; or somethin simillar

But such inaccuracy exists in the commands of other interfaces. Only one is enaught precise (Setting the href attribute must run these steps):
2. If the context object is a URL object and its url is null, throw a TypeError exception. 

===

Algo &quot;application/x-www-form-urlencoded serializer&quot; takes a list of name-value pairs pairs. What its exactly means? Take copy of that list or operate on original list?

I ask because in some steps I see this:

3. For each pair in pairs, run these substeps:
 3.1 Replace pair&apos;s name and value with the result of running encode on them using encoding override, respectively.
 3.2. Replace pair&apos;s name and value with their serialization. 

So &quot;replace pairs&apos;s name&quot; and replace &quot;pair&apos;s value&quot; means that we modificate a original list? Or we should get only string value of pair&apos;s name and pair&apos;s value, replace only this strings and add them to output?

===

And last, how treat argument (or arguments) passing to URLSearchParams&apos;s methods? 

Look, I analize only  append(name, value):
1. Append a new name-value pair whose name is name and value is value, to the list of name-value pairs.

But name and value should be encode/decode, percent encode/decode, etc. before append to list? When we use constructor URLSearchParams() we see that step:
3. If init is a string, set query&apos;s associated list of name-value pairs to the result of parsing input.

I check this in Firefox (now only this browser support URLSearchParams interface):

&lt;script&gt;
 var new_USP1 = new URLSearchParams(&quot;$=%C4%87&quot;);

 document.write(new_USP1); // &quot;%24=%C4%87&quot;

 document.write(&quot;&lt;br&gt;&quot;);

 var new_USP2 = new URLSearchParams(&quot;&quot;);
 new_USP2.append(&quot;$&quot;, &quot;%C4%87&quot;);

 document.write(new_USP2); &quot;%24=%25C4%2587&quot;
&lt;/script&gt;

We see that Firefox for append() change &quot;%&quot; to &quot;%25&quot; but for constructor don&apos;t do this. Alghoritms for URLSearchParams&apos;s methods don&apos;t mention anything about transform arguments (and it&apos;s hard to determine the correct behavior). In the other site, when use simillar command (like URLSearchParams(), setting URLUtils.search or URLUtils.href) its happend.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112463</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-30 13:58:12 +0000</bug_when>
    <thetext>That&apos;s a lot in one bug...

https://github.com/whatwg/url/commit/8770789a8583bf356d3dcedab8d1ad0bd69b53fb

... has fixes for the first two problems.


# What its exactly means? 
# Take copy of that list or operate on original list?

That&apos;s a good question. The algorithm should make a copy I think.


# And last, how treat argument (or arguments) 
# passing to URLSearchParams&apos;s methods? 

There should be no special handling. Only when parsing and serializing have special handling. The actual contents are &quot;decoded&quot;, so to say.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112468</commentid>
    <comment_count>2</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-09-30 14:40:58 +0000</bug_when>
    <thetext>(In reply to Anne from comment #1)

&gt; That&apos;s a lot in one bug...

If necessary can be split:)

&gt; There should be no special handling. Only when parsing and serializing have
&gt; special handling. The actual contents are &quot;decoded&quot;, so to say.

Ok, now understand this difference, I will check this methods in Firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112531</commentid>
    <comment_count>3</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-10-01 13:58:01 +0000</bug_when>
    <thetext>Anne, after  &quot;Make URLSearchParams’s list explicit&quot; you can also change &quot;list of name-value pairs&quot; to &quot;list&quot; and refer to it in:

- set the input (step 5.2 and 6.)
- setting search (step 2. and 6.)
- setting searchParams (step 5.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112573</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-02 12:20:35 +0000</bug_when>
    <thetext>https://github.com/whatwg/url/commit/25c7b7e7f6ac87105b84e849f5070e553b0ec9a5
https://github.com/whatwg/url/commit/367e30e049635d7e0310ee58cb8efc9688bdf2f9

Anything else?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112577</commentid>
    <comment_count>5</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-10-02 12:55:42 +0000</bug_when>
    <thetext>&gt; Anything else?

Hmm maybe explicitly add the initial values​​ in some cases:

https://url.spec.whatwg.org/#concept-urlsearchparams-url-object
&quot;A URLSearchParams object has an associated list of zero or more url objects&quot; &lt;&lt; add &quot;, which is initially empty.&quot;

https://url.spec.whatwg.org/#concept-url-fragment
Add &quot;It is initially null.&quot;

https://url.spec.whatwg.org/#concept-url-object
Add &quot;It is initially null.&quot;

https://url.spec.whatwg.org/#concept-urlutils-query-object
This should has initial value too, maybe here:
&quot;Unless stated otherwise, query encoding is utf-8.&quot; &lt;&lt; add &quot; and query object is null.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112584</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-02 14:09:32 +0000</bug_when>
    <thetext>https://github.com/whatwg/url/commit/2063402c3ec1d6a7de5e3f267e4009823a7674dd

Awesome, thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>