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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>131074</bug_id>
          
          <creation_ts>2014-04-01 16:03:57 -0700</creation_ts>
          <short_desc>document.createElement() should always return an element in the HTML namespace</short_desc>
          <delta_ts>2023-01-03 16:36:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Bates">dbates</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>996498</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2014-04-01 16:03:57 -0700</bug_when>
    <thetext>According to &lt;http://dom.spec.whatwg.org/#dom-document-createelement&gt; (20 March 2014), document.createElement() should always return an element in the HTML namespace:

[[
The createElement(localName) method must run the these steps:

1. If localName does not match the Name production, throw an &quot;InvalidCharacterError&quot; exception.

2. If the context object is an HTML document, let localName be converted to ASCII lowercase.

3. Let interface be the element interface for localName and the HTML namespace.

4. Return a new element that implements interface, with no attributes, namespace set to the HTML namespace, local name set to localName, and node document set to the context object.
]]

At the time of writing, document.createElement() [1] returns an element in the HTML namespace for an XHTML document. Otherwise, it returns an element in the &quot;null namespace&quot;.

[1] &lt;http://trac.webkit.org/browser/trunk/Source/WebCore/dom/Document.cpp?rev=166600#L854&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>996866</commentid>
    <comment_count>1</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2014-04-02 14:43:31 -0700</bug_when>
    <thetext>For completeness, I ran into this issue when merging a Blink patch in bug #131079.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1897884</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-09-12 09:15:01 -0700</bug_when>
    <thetext>rniwa@webkit.org - Is this something still needed or an issue? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898006</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-09-12 14:33:51 -0700</bug_when>
    <thetext>Running this in Web Inspector console for a HTML webpage, looks like this is fixed.

&gt; document.createElement(&quot;a&quot;)
&lt; &lt;a&gt;&lt;/a&gt;
&gt; $1.namespaceURI
&lt; &quot;http://www.w3.org/1999/xhtml&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922746</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-01-03 16:36:23 -0800</bug_when>
    <thetext>We have FIXME about this bug in here:

https://github.com/WebKit/WebKit/blob/main/LayoutTests/resources/js-test.js#L19

Should we modify our js-test.js script to update this?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>