A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members).

Difference between revisions of "CustomData"

From WHATWG Wiki
Jump to: navigation, search
(Why?)
(Rejected)
Line 13: Line 13:
 
<pre>
 
<pre>
 
<span custom:my-thing="50" custom:my-other-thing="4,5,1,2">bla bla</span>
 
<span custom:my-thing="50" custom:my-other-thing="4,5,1,2">bla bla</span>
 +
(rejected because colons have special meaning in XML and so this would lead to
 +
the HTML and XML DOM representations differing, which violates our intent to
 +
keep the DOM accessors serialisation-agnostic.)
 
</pre>
 
</pre>
  
 
<pre>
 
<pre>
<span custom-my-thing="50" custom-my-other-thing="4,5,1,2">bla bla</span>
+
<span><param name=my-thing value="50"><param name=my-other-thing value="4,5,1,2">bla bla</span>
 +
(rejected because it's so verbose that people would likely just do what
 +
they do now, violating the spec, instead of using it.)
 
</pre>
 
</pre>
  
 
<pre>
 
<pre>
<span><param name=my-thing value="50"><param name=my-other-thing value="4,5,1,2">bla bla</span>
+
<span custom-my-thing="50" custom-my-other-thing="4,5,1,2">bla bla</span>
 +
(rejected because "custom-" is not as good a prefix as "data-".)
 
</pre>
 
</pre>
 
What are the reasons for rejection?  The first uses namespaces which suck, and the third is super verbose, but what's wrong with the second?
 

Revision as of 20:51, 4 April 2008

Here are some ideas for how to include custom data in HTML documents.

Candidates

<span data-thing="50" data-doohickey="4,5,1,2">bla bla</span>

if (span.dataset.thing > 10) { ... }
span.dataset.doohickey = '1,2,3,4';

Rejected

<span custom:my-thing="50" custom:my-other-thing="4,5,1,2">bla bla</span>
(rejected because colons have special meaning in XML and so this would lead to
the HTML and XML DOM representations differing, which violates our intent to
keep the DOM accessors serialisation-agnostic.)
<span><param name=my-thing value="50"><param name=my-other-thing value="4,5,1,2">bla bla</span>
(rejected because it's so verbose that people would likely just do what
they do now, violating the spec, instead of using it.)
<span custom-my-thing="50" custom-my-other-thing="4,5,1,2">bla bla</span>
(rejected because "custom-" is not as good a prefix as "data-".)