Skip to content

Commit 4cb84de

Browse files
Added some additional tests for dots inside id/cass selectors
Code by @vovayatsyuk, thanks.
1 parent 9ce28b2 commit 4cb84de

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

test/modules/traversal.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ var fixture = '\
1313
<div class="uncle"></div>\
1414
<div class="aunt"></div>\
1515
</div>\
16+
<div class="dotsgrandparent">\
17+
<div class="dotsparent">\
18+
<div class="dots.first"></div>\
19+
<div id="id.with.dots" class="class.with.dots"></div>\
20+
</div>\
21+
</div>\
1622
<iframe src="about:blank"></iframe>\
1723
';
1824

@@ -36,6 +42,22 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
3642

3743
});
3844

45+
it ( 'supports filtering by a class with dots', function ( t ) {
46+
47+
var children = $('.dotsparent').children ( '.class\\.with\\.dots' );
48+
49+
t.is ( children.length, 1 );
50+
51+
});
52+
53+
it ( 'supports filtering by a id with dots', function ( t ) {
54+
55+
var children = $('.dotsparent').children ( '#id\\.with\\.dots' );
56+
57+
t.is ( children.length, 1 );
58+
59+
});
60+
3961
});
4062

4163
describe ( '$.fn.closest', function ( it ) {
@@ -112,9 +134,11 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
112134
var grandparent = $('.grandparent');
113135
var all = grandparent.find ( '*' );
114136
var siblings = grandparent.find ( '.sibling' );
137+
var dots = $('.dotsparent').find ( '.class\\.with\\.dots' );
115138

116139
t.is ( all.length, 8 );
117140
t.is ( siblings.length, 5 );
141+
t.is ( dots.length, 1 );
118142

119143
});
120144

@@ -154,6 +178,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
154178

155179
});
156180

181+
it ( 'supports dots in selectors', function ( t ) {
182+
183+
var eles = $('.dotsgrandparent').children ();
184+
185+
t.is ( eles.has ( '.class\\.with\\.dots' ).length, 1 );
186+
t.is ( eles.has ( '#id\\.with\\.dots' ).length, 1 );
187+
188+
});
189+
157190
it ( 'supports nodes', function ( t ) {
158191

159192
var eles = $('.grandparent').children ();
@@ -182,6 +215,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
182215

183216
});
184217

218+
it ( 'check if the collection matches a selector with dots', function ( t ) {
219+
220+
var child = $('.class\\.with\\.dots');
221+
222+
t.true ( child.is ( '.class\\.with\\.dots' ) );
223+
t.true ( child.is ( '#id\\.with\\.dots' ) );
224+
225+
});
226+
185227
});
186228

187229
describe ( '$.fn.next', function ( it ) {
@@ -214,6 +256,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
214256

215257
});
216258

259+
it ( 'supports selector with dots', function ( t ) {
260+
261+
var child = $('.dots\\.first');
262+
var next = $('.class\\.with\\.dots');
263+
264+
t.deepEqual ( child.next ( '.class\\.with\\.dots' ).get (), next.get () );
265+
266+
});
267+
217268
});
218269

219270
describe ( '$.fn.nextAll', function ( it ) {

0 commit comments

Comments
 (0)