Attributes and "Expandos"

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?

 

---

<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:04:41 UTC