1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/js/attributes.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +<HTML> 1.5 +<HEAD> 1.6 + <TITLE>Attributes test</TITLE> 1.7 +</HEAD> 1.8 +<BODY bgColor="#ffffff" text="#000000"> 1.9 +<H1>Attributes test</H1> 1.10 + 1.11 +<P>You should see the following in the console:</P> 1.12 +<PRE> 1.13 +attribute.getNamedItem == getAttributeNode: true 1.14 +attribute BGCOLOR=#ffffff 1.15 +changing attribute node value changes attribute value: true 1.16 +return value of removeNamedItem is attribute node: true 1.17 +removing attribute changes attribute count: true 1.18 +changing disembodied attribute value works: true 1.19 +removing attribute node removes attribute: true 1.20 +</PRE> 1.21 + 1.22 +<P>The text should turn green and then you should see 1.23 +the following in the console:</P> 1.24 +<PRE> 1.25 +setting an existing attribute returns the old node: true 1.26 +</PRE> 1.27 + 1.28 +<SCRIPT> 1.29 +a = document.body.attributes.getNamedItem("bgcolor") 1.30 +a2 = document.body.getAttributeNode("bgcolor") 1.31 +n = document.body.attributes.length; 1.32 +dump("attribute.getNamedItem == getAttributeNode: " + (a == a2) + "\n"); 1.33 + 1.34 +dump("attribute " + a.name + "=" + a.value + "\n"); 1.35 + 1.36 +a.value = "#00ffff" 1.37 +dump("changing attribute node value changes attribute value: " + (document.body.getAttribute("bgcolor") == "#00ffff") + "\n"); 1.38 + 1.39 +a = document.body.attributes.removeNamedItem("bgcolor") 1.40 +dump("return value of removeNamedItem is attribute node: " + (a == a2) + "\n"); 1.41 + 1.42 +dump("removing attribute changes attribute count: " + (document.body.attributes.length == (n-1)) + "\n"); 1.43 + 1.44 +a.value = "#ff0000" 1.45 +dump("changing disembodied attribute value works: " + (a.value == "#ff0000") + "\n"); 1.46 + 1.47 +dump("removing attribute node removes attribute: " + (document.body.getAttribute("bgcolor") == "") + "\n"); 1.48 + 1.49 +a = document.body.attributes.getNamedItem("TEXT"); 1.50 +a2 = document.createAttribute("text"); 1.51 +a2.value = "#00ff00"; 1.52 +a3 = document.body.attributes.setNamedItem(a2); 1.53 +dump("setting an existing attribute returns the old node: " + (a == a3) + "\n"); 1.54 +</SCRIPT> 1.55 + 1.56 +</BODY> 1.57 +</HTML> 1.58 +