<?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>27065</bug_id>
          
          <creation_ts>2014-10-15 21:06:56 +0000</creation_ts>
          <short_desc>searchParams attribute should always return URLSearchParams object or sometimes null?</short_desc>
          <delta_ts>2014-10-16 11:32:51 +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>113245</commentid>
    <comment_count>0</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-10-15 21:06:56 +0000</bug_when>
    <thetext>I mention about this in bug https://www.w3.org/Bugs/Public/show_bug.cgi?id=27022#c1.

Now only Firefox support URLSearchParams so examples will presents result only for this browser. There still is space for corect this browser or change something in URL spec.

By spec &quot;query object&quot; can be set from null to URLSearchParams when &quot;set the input&quot; is used. In some case null will stay, but in IDL I don&apos;t see nullable type for .searchParams. 

Simple case:

var someURL = new URL(&quot;aaa:bbb&quot;);

If I understand all algos, then this step from &quot;set the input&quot;:
  5. If url is non-null and its relative flag is set, run these substeps
will be never executed and &quot;query object&quot; stay with null (initial value) and someURL.searchParams should return null.

Next case is important for HTML, how treat this:

&lt;a&gt;
&lt;a href=&quot;parserReturnError&quot;&gt;

a.searchParams should return null or URLSearchParams object with empty list?
Now HTML denided this wrong (https://www.w3.org/Bugs/Public/show_bug.cgi?id=27047) but before correct HTML, URL spec should be correct.

What can I add is that Firefox always create URLSearchParams.

&lt;a id=&quot;a1&quot;&gt;&lt;/a&gt;
&lt;a id=&quot;a2&quot; href&gt;&lt;/a&gt;
&lt;a id=&quot;a3&quot; href=&quot;abc:def&quot;&gt;&lt;/a&gt;

&lt;script&gt;

 var a1 = document.getElementById(&quot;a1&quot;);
 var a2 = document.getElementById(&quot;a2&quot;); // the same as href=&quot;&quot; and probably use base URL
 var a3 = document.getElementById(&quot;a3&quot;);

 var a4 = new URL(&quot;abc:def&quot;);

 document.write(a1.searchParams.append + &quot;&lt;br&gt;&lt;br&gt;&quot;); // function append() { [native code] }

 document.write(a2.searchParams.append + &quot;&lt;br&gt;&lt;br&gt;&quot;); // function append() { [native code] }

 document.write(a3.searchParams.append + &quot;&lt;br&gt;&lt;br&gt;&quot;); // function append() { [native code] }

 document.write(a4.searchParams.append + &quot;&lt;br&gt;&lt;br&gt;&quot;); // function append() { [native code] }

&lt;/script&gt;

This is still fresh and can be easy correct (by URL spec or Firefox) but its important what behaviour is excepted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113253</commentid>
    <comment_count>1</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-10-15 22:37:51 +0000</bug_when>
    <thetext>Now I realize that this in &quot;set the input&quot; is strange:

 5. If url is non-null and its relative flag is set, run these substeps...

Why &quot;relative flag&quot; is used here? Non-relative URL can have query (and set/get by search property). So when &quot;set the input&quot; is used for this URL then URLSearchParams shuld be create too and let us to easy manipulate query.

Can&apos;t show this behaviour in actual browser because Firefox doesn&apos;t set query and Chrome set (but doesn&apos;t support URLSearchParams).

&lt;script&gt;

 var someURL = new URL(&quot;abc:def?a=b&quot;);

 document.write(someURL.search + &quot;&lt;br&gt;&lt;br&gt;&quot;); // Chrome &quot;?aa&quot;, Firefox &quot;&quot;

 someURL.search = &quot;test&quot;;

 document.write(someURL.search + &quot;&lt;br&gt;&lt;br&gt;&quot;); // Chrome &quot;?test&quot;, Firefox &quot;&quot;

&lt;/script&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113296</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-16 11:32:51 +0000</bug_when>
    <thetext>https://github.com/whatwg/url/commit/217cf06b9d2b7fbbbf65eec9d1ea9fce66fec8bf</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>