<?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>27228</bug_id>
          
          <creation_ts>2014-11-03 23:52:23 +0000</creation_ts>
          <short_desc>Inconsistency in characters allowed in attribute names between setAttribute and HTML syntax specs</short_desc>
          <delta_ts>2017-04-26 16:50:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</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="Igor Minar">igor</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>annevk</cc>
    
    <cc>crimsteam</cc>
    
    <cc>d</cc>
    
    <cc>davidsouther</cc>
    
    <cc>deepak.sa</cc>
    
    <cc>dglazkov</cc>
    
    <cc>glenn</cc>
    
    <cc>joe</cc>
    
    <cc>mike</cc>
    
    <cc>misko</cc>
    
    <cc>www-dom</cc>
    
    <cc>XX1011</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114462</commentid>
    <comment_count>0</comment_count>
    <who name="Igor Minar">igor</who>
    <bug_when>2014-11-03 23:52:23 +0000</bug_when>
    <thetext>According to http://www.w3.org/TR/html5/syntax.html#attributes-0 and http://www.w3.org/TR/html5/syntax.html#attribute-name-state non-ascii characters like &quot;[&quot;, &quot;]&quot;, &quot;(&quot;, &quot;)&quot; and &quot;?&quot; are valid characters for attribute names.

However, according to https://dom.spec.whatwg.org/#dom-element-setattribute setAttribute allows only attribute names that contain ascii characters.

This means that while &lt;div [foo]=&quot;bar&quot;&gt; is properly parsed by all browsers that I tried (Chrome, FF, Safari, IE), trying to set attributes via DOM apis throws an exception in all of these browsers.

There is a workaround for this (http://jsperf.com/specialsetattribute) that comes with a performance hit.

It would be great to have the setAttribute spec match the html syntax spec, so that we don&apos;t need to be working around the more restrictive DOM spec and taking a perf hit.

The real-world usecase for this usage is DOM-based templating systems like those used by Angular and Polymer. Polymer already uses &lt;my-component hidden?=&quot;{{exp}}&quot;&gt;&lt;/&gt; (note the &quot;?&quot; after hidden), and Angular is considering using &lt;my-component [hidden]=&quot;exp&quot;&gt;&lt;/&gt; syntax for our next generation templating. The use of attribute name and &quot;odd&quot; characters is exactly what we need to build a templating language on top of HTML and DOM that will work well with Web Components.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114463</commentid>
    <comment_count>1</comment_count>
    <who name="Glenn Adams">glenn</who>
    <bug_when>2014-11-04 00:25:05 +0000</bug_when>
    <thetext>(In reply to Igor Minar from comment #0)
&gt; According to http://www.w3.org/TR/html5/syntax.html#attributes-0 and
&gt; http://www.w3.org/TR/html5/syntax.html#attribute-name-state non-ascii
&gt; characters like &quot;[&quot;, &quot;]&quot;, &quot;(&quot;, &quot;)&quot; and &quot;?&quot; are valid characters for
&gt; attribute names.

&quot;[&quot;, &quot;]&quot;, &quot;(&quot;, &quot;)&quot; and &quot;?&quot; *ARE* ASCII characters; all Unicode code points from 0x00 through 0x7F are ASCII characters. [1]

[1] http://en.wikipedia.org/wiki/ASCII
[2] http://www.unicode.org/charts/PDF/U0000.pdf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114465</commentid>
    <comment_count>2</comment_count>
    <who name="Igor Minar">igor</who>
    <bug_when>2014-11-04 00:35:39 +0000</bug_when>
    <thetext>Glenn, you are right. That was an imprecision on my part. The character set for setAttribute is defined as http://www.w3.org/TR/xml/#NT-NameChar which is a doesn&apos;t match the character set defined in the html syntax spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114473</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-04 08:34:47 +0000</bug_when>
    <thetext>This has the same issue as bug 24271. We would need browsers to risk web compatibility.

Dmitry, is Chrome willing to be a guinea pig?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114511</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-11-04 21:36:34 +0000</bug_when>
    <thetext>(In reply to Anne from comment #3)
&gt; This has the same issue as bug 24271. We would need browsers to risk web
&gt; compatibility.
&gt; 
&gt; Dmitry, is Chrome willing to be a guinea pig?

It might be good to bring this up on blink-dev and take the temperature. I wonder how we could pre-emptively measure the impact of this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114513</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-04 21:47:23 +0000</bug_when>
    <thetext>I don&apos;t know. I&apos;m not particularly concerned by the mismatch myself. I&apos;m happy for someone to take this on though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122395</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-03 10:48:38 +0000</bug_when>
    <thetext>https://groups.google.com/a/chromium.org/d/msg/blink-dev/YyqxpIPU-0E/dXg0JBRVBwAJ

Leaving this open until that thread concluded something one way or another or enough time expired that indicates nobody is really interested in taking the lead here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122399</commentid>
    <comment_count>7</comment_count>
    <who name="Joe Gregorio">joe</who>
    <bug_when>2015-08-03 11:54:06 +0000</bug_when>
    <thetext>For my own edification, won&apos;t that workaround stop working when browsers move to DOM 4 and Attr no longer inherits from Node and thus cloneNode() is no longer available?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125460</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-03-14 13:05:03 +0000</bug_when>
    <thetext>Joe, yeah, though it seems unlikely we&apos;ll be able to cut the tie between Attr and Node. See https://github.com/whatwg/dom/issues/102 for details.

Closing this since nothing actionable came out of this and nobody seems keen on running experiments. Sorry Igor.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128551</commentid>
    <comment_count>9</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2017-04-26 16:50:09 +0000</bug_when>
    <thetext>This is getting a new attempt at https://github.com/whatwg/dom/pull/449, with Chrome helping measure things per https://bugs.chromium.org/p/chromium/issues/detail?id=648179.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>