@@ -12,6 +12,7 @@ describe('color-contrast-matches', function () {
12
12
13
13
afterEach ( function ( ) {
14
14
fixture . innerHTML = '' ;
15
+ axe . _tree = undefined ;
15
16
} ) ;
16
17
17
18
it ( 'is a function' , function ( ) {
@@ -22,42 +23,48 @@ describe('color-contrast-matches', function () {
22
23
fixture . innerHTML = '<div style="color: yellow; background-color: white;" id="target">' +
23
24
' </div>' ;
24
25
var target = fixture . querySelector ( '#target' ) ;
25
- assert . isFalse ( rule . matches ( target ) ) ;
26
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
27
+ assert . isFalse ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
26
28
} ) ;
27
29
28
30
it ( 'should match when there is text' , function ( ) {
29
31
fixture . innerHTML = '<div style="color: yellow; background-color: white;" id="target">' +
30
32
'My text</div>' ;
31
33
var target = fixture . querySelector ( '#target' ) ;
32
- assert . isTrue ( rule . matches ( target ) ) ;
34
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
35
+ assert . isTrue ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
33
36
} ) ;
34
37
35
38
it ( 'should not match when there is text that is out of the container' , function ( ) {
36
39
fixture . innerHTML = '<div style="color: yellow; text-indent: -9999px; background-color: white;" id="target">' +
37
40
'My text</div>' ;
38
41
var target = fixture . querySelector ( '#target' ) ;
39
- assert . isFalse ( rule . matches ( target ) ) ;
42
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
43
+ assert . isFalse ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
40
44
} ) ;
41
45
42
46
it ( 'should not match when there is text that is out of the container with overflow hidden' , function ( ) {
43
47
fixture . innerHTML = '<div style="color: yellow; width: 100px; overflow: hidden; text-indent: 200px; background-color: white;" id="target">' +
44
48
'text</div>' ;
45
49
var target = fixture . querySelector ( '#target' ) ;
46
- assert . isFalse ( rule . matches ( target ) ) ;
50
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
51
+ assert . isFalse ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
47
52
} ) ;
48
53
49
54
it ( 'should match when there is text that is in the scroll reach of container' , function ( ) {
50
55
fixture . innerHTML = '<div style="color: yellow; width: 100px; overflow: scroll; text-indent: 200px; background-color: white;" id="target">' +
51
56
'text</div>' ;
52
57
var target = fixture . querySelector ( '#target' ) ;
53
- assert . isTrue ( rule . matches ( target ) ) ;
58
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
59
+ assert . isTrue ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
54
60
} ) ;
55
61
56
62
it ( 'should match when there is text that is only partially out of the container' , function ( ) {
57
63
fixture . innerHTML = '<div style="color: yellow; text-indent: -20px; background-color: white;" id="target">' +
58
64
'My text</div>' ;
59
65
var target = fixture . querySelector ( '#target' ) ;
60
- assert . isTrue ( rule . matches ( target ) ) ;
66
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
67
+ assert . isTrue ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
61
68
} ) ;
62
69
63
70
it ( 'should match <input type="text">' , function ( ) {
@@ -148,7 +155,8 @@ describe('color-contrast-matches', function () {
148
155
it ( 'should match <button>' , function ( ) {
149
156
fixture . innerHTML = '<button>hi</button>' ;
150
157
var target = fixture . querySelector ( 'button' ) ;
151
- assert . isTrue ( rule . matches ( target ) ) ;
158
+ var tree = axe . _tree = axe . utils . getFlattenedTree ( fixture ) ;
159
+ assert . isTrue ( rule . matches ( target , axe . utils . getNodeFromTree ( tree [ 0 ] , target ) ) ) ;
152
160
} ) ;
153
161
154
162
it ( 'should not match <button disabled>' , function ( ) {
0 commit comments