<?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>25016</bug_id>
          
          <creation_ts>2014-03-12 02:28:44 +0000</creation_ts>
          <short_desc>AttrExodus: Element.getAttributeNode</short_desc>
          <delta_ts>2014-08-19 10:21:27 +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>FIXED</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="Philip Jägenstedt">philipj</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>ehsan</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>102226</commentid>
    <comment_count>0</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-03-12 02:28:44 +0000</bug_when>
    <thetext>http://www.chromestatus.com/metrics/feature/timeline/popularity/107

Usage is too high to make removal realistic. Simplification with a dumber Attr interface is hopefully still possible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102454</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-17 15:24:45 +0000</bug_when>
    <thetext>How about setAttributeNode() then?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102534</commentid>
    <comment_count>2</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-03-18 08:10:58 +0000</bug_when>
    <thetext>Here are all the interesting counters:

Element.getAttributeNode: http://www.chromestatus.com/metrics/feature/timeline/popularity/107
Element.getAttributeNodeNS: http://www.chromestatus.com/metrics/feature/timeline/popularity/110
Element.setAttributeNode: http://www.chromestatus.com/metrics/feature/timeline/popularity/108
Element.removeAttributeNode: http://www.chromestatus.com/metrics/feature/timeline/popularity/109
Document.createAttribute: http://www.chromestatus.com/metrics/feature/timeline/popularity/111
Document.createAttributeNS: http://www.chromestatus.com/metrics/feature/timeline/popularity/112 (already removed from Blink)

setAttributeNode(), at ~0.15% is also above the threshold for removal. The only ones clearly below are getAttributeNodeNS() and removeAttributeNode().

I assume that the way things would be spec&apos;d is to have getAttributeNode() return one of the objects in the children array and for setAttributeNode(node) to just call setAttribute(node.name, node.value)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102540</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-18 10:19:52 +0000</bug_when>
    <thetext>If we are going to have createAttribute(), and getAttributeNode() / setAttributeNode(), I would expect these signatures:

Attr createAttribute(DOMString localName)
Attr? getAttributeNode(DOMString name)
Attr? setAttributeNode(Attr attribute)

And roughly equivalent semantics to how they are implemented today, including throwing &quot;InuseAttributeError&quot;.

Note that createAttribute() is different between Gecko and WebKit/Blink. Gecko&apos;s behavior makes more sense given the lack of namespaces.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102576</commentid>
    <comment_count>4</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-03-18 17:14:20 +0000</bug_when>
    <thetext>In other words, the association with an element is coming back just to support throwing an exception? If so it&apos;s just as well to make setting/getting the Attr.value use the associated element as well.

Getting rid of that association seemed like a very nice thing...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102577</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-18 17:21:14 +0000</bug_when>
    <thetext>There was always an assocation. An element holds a list of attributes after all. Given that, throwing for

  document.head.setAttributeNode(document.body.attributes[0])

seems cheap. How did you envision getting rid of it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102584</commentid>
    <comment_count>6</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-03-18 17:49:23 +0000</bug_when>
    <thetext>Since the Attr.value setter in the current spec doesn&apos;t seem to update the associated Element&apos;s attribute, I assumed the plan was to let an Attr not known about where it came from at all, so that the setter wouldn&apos;t actually do anything useful.

Instead of me making guesses, how about you tell me how simple you think Attr can realistically become, and I can try to add Blink use counters to check specific scenarios?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102586</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-18 17:53:47 +0000</bug_when>
    <thetext>An Attr object *is* an attribute. Therefore updating an Attr object&apos;s value, updates an attribute (they&apos;re the same). I see now that the specification does invoke the right algorithm for the value setter, but forgets to fill in the element argument. That&apos;s a bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102587</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-18 17:55:46 +0000</bug_when>
    <thetext>So to answer your question: Attributes will have to remain mutable objects. However, hopefully they do not need to inherit from Node and hopefully they do not need to have children.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102590</commentid>
    <comment_count>9</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-03-18 18:01:39 +0000</bug_when>
    <thetext>OK, in that case I&apos;ll close https://codereview.chromium.org/203313002/ and lower my expectations for Attr simplification :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110222</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-18 11:15:39 +0000</bug_when>
    <thetext>Philip, I changed my mind and you are correct. Could we start measuring that? Not having an association between an attribute and its element would be great. I&apos;m updating the specification to align with your goals.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110225</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-18 11:25:36 +0000</bug_when>
    <thetext>Philip, usage is too high a for a deprecation for these?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110228</commentid>
    <comment_count>12</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-08-18 12:14:42 +0000</bug_when>
    <thetext>I just filed bug 26596 which would amount to surrender, keeping a connection between Attr and its Element.

After the previous round of comments I added the AttrSetValueWithElement use counter, which leaves little hope for simplification:
http://www.chromestatus.com/metrics/feature/timeline/popularity/303

If there&apos;s anything left worth trying/measuring, let me know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110239</commentid>
    <comment_count>13</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-18 14:20:30 +0000</bug_when>
    <thetext>*** Bug 25370 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110244</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-18 15:45:17 +0000</bug_when>
    <thetext>Done: createAttribute[NS]: https://github.com/whatwg/dom/commit/522710bc4be13d2e1d826f94c54d1de9956ec920 (Fallout is bug 26599 on abstracting out a common algorithm.)

Todo: Element.prototype.getAttributeNode[NS], Element.setAttributeNode[NS], removeAttributeNode (no NS version), NamedNodeMap.prototype.setNamedItem[NS].

As discussed on IRC it probably makes no sense to try to remove any of these as the complexity in all of them is the concept of attributes holding a reference to their element and we cannot get rid of that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110246</commentid>
    <comment_count>15</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-18 17:36:49 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/5a881d9b5f328f8e32f0fa8e73b4e8799772cb0c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110288</commentid>
    <comment_count>16</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-08-19 10:21:27 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/12d011437faef5ada7b816c94aab39b10cdb2f4b

All these methods are back now :-( Sad times. Will try to look into doing a bit more consolidating of algorithms.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>