13 #style_active:active {
14 background-color: blue;
16 :indeterminate + span {
17 background-color: blue;
22 <div style=
"position: absolute; left: 8px; top: 66px; width: 400px; height: 30px;">
23 <span id=
"target">This has multiple listeners.
</span>
24 <div id=
"mutate">This block gets mutated to change the DOM.
</div>
25 <div id=
"style_active">This block gets red if active
</div>
26 <input id=
"checkbox" type=
"checkbox"><span>indeterminate checkbox
</span>
29 <p style=
"position: absolute; left: 8px; top: 400px; width: 400px; height: 30px;"><span id=
"bottom">Bottom.
</span></p>
34 function setTest(whichTest
) {
37 function hasTest(operation
, handler
) {
38 var candidate
= operation
+ '-' + handler
;
39 var result
= test
=== candidate
;
42 function handle(event
) {
43 var operation
= event
.type
;
44 if (hasTest(operation
, 'mutateDom')) {
46 mutate
.textContent
= 'This block HAS BEEN mutated ' + mutations
+ ' times!';
47 } else if (hasTest(operation
, 'mutateStyle')) {
48 mutate
.style
.color
= mutate
.style
.color
== "red" ? "blue" : "red";
49 } else if (hasTest(operation
, 'mutateIndeterminate')) {
50 checkbox
.indeterminate
^= true;
51 } else if (hasTest(operation
, 'preventDefault')) {
52 event
.preventDefault();
55 var t
= document
.getElementById('target');
56 t
.addEventListener('mousedown', handle
);
57 t
.addEventListener('mouseup', handle
);
58 t
.addEventListener('mousemove', handle
);
59 t
.addEventListener('click', handle
);