- From: Maciej Stachowiak <mjs@apple.com>
- Date: Fri, 22 Jun 2007 11:43:21 -0700
- To: Travis Leithead <travil@windows.microsoft.com>
- Cc: ian@hixie.ch, public-html@w3.org, Chris Wilson <chris.wilson@microsoft.com>
- Message-Id: <118E8A7F-DA7B-409B-9919-B63E5EF589BD@apple.com>
On Jun 22, 2007, at 10:12 AM, Travis Leithead wrote: > Using HTML5 terminology: Current browsers today put all unknown > content attributes (namespace, name and value) into the DOM and can > be [case insensitively] retrieved via getAttribute[NS] and > getAttributeNode[NS], set via setAttribute[NS] and setAttributeNode > [NS], and removed via removeAttribute[NS] and removeAttributeNode. > > IE, has the concept of “expandos”, meaning it also creates > reflecting DOM attributes on the corresponding element for unknown > content attributes (case-sensitive). Obviously HTML5 does not > define DOM attributes for unknown content attributes, however is > there any general guidelines for reflecting (or not) unknown > content attributes in the DOM, or is that left to the UA’s discretion? HTML5 doesn't have a requirement forbidding any kind of additional attributes. However, some aspects of IE's DOM reflection are problematic, and it would be better to treat the DOM element JS attribute namespace as separate from the attribute namespace. I think the following two aspects are non-conforming, although mainly to DOM Core rather than to HTML5: 1) getAttribute sometimes returns a non-string, for standard attributes that have corresponding non-string DOM attributes. For example getAttribute("onclick"). 2) Setting a custom property on an element results in an attribute on the element that is visible to getAttribute and serialized via innerHTML. I don't think adding a custom property for a nonstandard attribute is nonconforming to anything, but is likely to cause compatibility problems with scripts as the language evolves and is probably more confusing than helpful if you fix issues 1 and 2. Other browsers generally don't have this IE-specific quirk. Regards, Maciej > > --- > <body onload="check()"> > <a href="foo.html" myExpando="bar"> > <script type=text/javascript> > function check() > { > var anchor = document.getElementsByTagName('a').item > (0); > > alert("Is a reflecting DOM attribute dynamically > created? (case-insensitive) anchor.myexpando {" + anchor.myexpando > + "}\n" + > "Is a reflecting DOM attribute dynamically > created? (case-sensitive) anchor.myExpando {" + anchor.myExpando + > "}\n" + > "Is a content attribute created? (case- > insensitive) anchor.getAttribute('myexpando') {" + > anchor.getAttribute('myexpando') + "}\n" + > "Is a content attribute created? (case- > sensitive) anchor.getAttribute('myExpando') {" + anchor.getAttribute > ('myExpando') + "}"); > > // Setting the anchor.myExpando reflects in the > // content attribute, and removing the content > // attribute removes the DOM attribute. > } > </script>
Received on Friday, 22 June 2007 18:43:39 UTC