root/collected/trunk/html-test-cases/setting-and-removing-tabindex.xhtml

Revision 53, 1.4 kB (checked in by simon, 3 years ago)

fixed a bug in the remove test -- the tabindex wasn't being added back before testing removeAttribute("tabIndex")

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
4<html xmlns="http://www.w3.org/1999/xhtml">
5
6<head>
7<title>Setting and removing the tabindex value of an element with JavaScript</title>
8<script type="text/javascript">
9function log(message){
10        text = document.createTextNode(message);
11        document.getElementById("log").appendChild(text);
12        document.getElementById("log").appendChild(document.createElement("br"));
13}
14function logSetAttribute(){
15        var input = document.createElement("input");
16        input.tabIndex = 1;
17        input.setAttribute("tabindex", 2);
18        log('setAttribute("tabindex")' + (input.tabIndex == 2 ? " yes" : " no"));
19        input.tabIndex = 1;
20        input.setAttribute("tabIndex", 2);
21        log('setAttribute("tabIndex")' + (input.tabIndex == 2 ? " yes" : " no"));
22}
23function hasTabindex(elem){
24        var attr = elem.getAttributeNode("tabindex");
25        return attr ? attr.specified : false;
26}
27function logRemoveAttribute(){
28        var input = document.createElement("input");
29        input.tabIndex = 1;
30        input.removeAttribute("tabindex");
31        log('removeAttribute("tabindex")' + (hasTabindex(input) ? " no" : " yes"));
32        input.tabIndex = 1;
33        input.removeAttribute("tabIndex");
34        log('removeAttribute("tabIndex")' + (hasTabindex(input) ? " no" : " yes"));
35}
36function run(){
37        logSetAttribute();
38        logRemoveAttribute();
39}
40</script>
41</head>
42
43<body onload="run()">
44<p id="log"></p>
45</body>
46
47</html>
Note: See TracBrowser for help on using the browser.