<?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>22914</bug_id>
          
          <creation_ts>2013-08-11 13:55:25 +0000</creation_ts>
          <short_desc>Unclear if setting element.dataset.fooBar should update data-foo-bar attribute</short_desc>
          <delta_ts>2013-10-02 14:23:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>CR</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Karger">karger</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>robin</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91871</commentid>
    <comment_count>0</comment_count>
    <who name="David Karger">karger</who>
    <bug_when>2013-08-11 13:55:25 +0000</bug_when>
    <thetext>Spec section 3.2.3.9 on custom data attributes specifies how hyphenated data-* attribute names are converted to camelCase for inclusion in an element&apos;s dataset which is a DomStringMap.  And precise specifications are given for how names are read and updated in a DomStringMap.  However the specification is mute on whether an update to a name&apos;s value in the DomStringMap should cause an update to the corresponding content attribute in the underlying element.  

In jquery, for example, data-* attributes are read into the DomStringMap on first access, but changes to the corresponding values in the DomStringMap are *not* pushed back as changes to the DOM node&apos;s content attributes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91872</commentid>
    <comment_count>1</comment_count>
    <who name="David Karger">karger</who>
    <bug_when>2013-08-11 14:32:49 +0000</bug_when>
    <thetext>Having read some more spec I can simplify the question: are custom data elements in element.dataset required to reflect the corresponding data-* content attributes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92252</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-08-19 06:07:23 +0000</bug_when>
    <thetext>This is actually fully specified, as far as I can tell.

Specifically, in section 3.2.3.9 the &quot;algorithm for setting names to certain values&quot; step 6 clearly says that setting a property on element.dataset sets the corresponding data-* attribute on the element.

So the answer to the question in comment 1 is &quot;Yes&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92304</commentid>
    <comment_count>3</comment_count>
    <who name="David Karger">karger</who>
    <bug_when>2013-08-19 22:42:24 +0000</bug_when>
    <thetext>Good; thanks for pointing that out.
I was investigating because jquery&apos;s .data() method, which seems awfully close to implementing the html5 spec, does *not* perform this reflection: it explicitly states that the .data() object is populated only once, and any future modifications to the object or to the DOM do not reflect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92857</commentid>
    <comment_count>4</comment_count>
    <who name="Robin Berjon">robin</who>
    <bug_when>2013-09-03 11:51:53 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the Editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this document:

   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: none
Rationale: Reflection is indeed specified here. David: the confusion here is that jQuery&apos;s data() is actually something rather different. You can use data-* attributes to store additional information on the tree, but it&apos;s limited to the sort of stuff you can put in an attribute value. jQuery&apos;s data() is used to add pretty much any kind of data that JS can hold to an element. You can include things like pointers to another node, or the complete implementation of a plugin (so that if a plugin instance is handling the element&apos;s behaviour, you can grab the instance and interact with it using data()). It&apos;s not the same thing, and you really couldn&apos;t reflect what jQuery does into the DOM (at least not in a way that could make sense serialised).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>