Keun young Park | 0c91f01 | 2012-11-27 09:04:40 -0800 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Descendant selectors</title> |
| 5 | <style> |
| 6 | div { padding: 1px; } |
| 7 | .test div { padding: 2px; } |
| 8 | .test2 div { padding: 3px; } |
| 9 | .test div div div { background: orange; } |
| 10 | .test div div div div { background: white; } |
| 11 | </style> |
| 12 | </head> |
| 13 | <body> |
| 14 | <script> |
| 15 | |
| 16 | var rootElement; |
| 17 | var totalHeight; |
| 18 | var DEFAULT_DEPTH = 1000; |
| 19 | |
| 20 | function setUp(opt_depth) { |
| 21 | var depth = opt_depth || DEFAULT_DEPTH; |
| 22 | rootElement = document.createElement('div'); |
| 23 | var parentElement = rootElement; |
| 24 | for (var i = 0; i < depth; i++) { |
| 25 | var element = document.createElement('div'); |
| 26 | element.appendChild(document.createTextNode(i)); |
| 27 | parentElement.appendChild(element); |
| 28 | parentElement = element; |
| 29 | } |
| 30 | document.body.appendChild(rootElement); |
| 31 | totalHeight = 0 |
| 32 | } |
| 33 | |
| 34 | function tearDown() { |
| 35 | rootElement.parentNode.removeChild(rootElement); |
| 36 | rootElement = null; |
| 37 | } |
| 38 | |
| 39 | function test(opt_depth) { |
| 40 | var depth = opt_depth || DEFAULT_DEPTH; |
| 41 | rootElement.className = rootElement.className == 'test' ? 'test2' : 'test'; |
| 42 | totalHeight += rootElement.offsetHeight; |
| 43 | } |
| 44 | </script> |
| 45 | <script src="../test.js"></script> |
| 46 | </body> |
| 47 | </html> |