From 4cb84de343f2b7b233b4c056827676203b11dd00 Mon Sep 17 00:00:00 2001 From: Fabio Spampinato Date: Fri, 18 Nov 2022 23:07:02 +0000 Subject: [PATCH] Added some additional tests for dots inside id/cass selectors Code by @vovayatsyuk, thanks. --- test/modules/traversal.js | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/modules/traversal.js b/test/modules/traversal.js index c57e554..7100545 100644 --- a/test/modules/traversal.js +++ b/test/modules/traversal.js @@ -13,6 +13,12 @@ var fixture = '\
\
\ \ +
\ +
\ +
\ +
\ +
\ +
\ \ '; @@ -36,6 +42,22 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function () }); + it ( 'supports filtering by a class with dots', function ( t ) { + + var children = $('.dotsparent').children ( '.class\\.with\\.dots' ); + + t.is ( children.length, 1 ); + + }); + + it ( 'supports filtering by a id with dots', function ( t ) { + + var children = $('.dotsparent').children ( '#id\\.with\\.dots' ); + + t.is ( children.length, 1 ); + + }); + }); describe ( '$.fn.closest', function ( it ) { @@ -112,9 +134,11 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function () var grandparent = $('.grandparent'); var all = grandparent.find ( '*' ); var siblings = grandparent.find ( '.sibling' ); + var dots = $('.dotsparent').find ( '.class\\.with\\.dots' ); t.is ( all.length, 8 ); t.is ( siblings.length, 5 ); + t.is ( dots.length, 1 ); }); @@ -154,6 +178,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function () }); + it ( 'supports dots in selectors', function ( t ) { + + var eles = $('.dotsgrandparent').children (); + + t.is ( eles.has ( '.class\\.with\\.dots' ).length, 1 ); + t.is ( eles.has ( '#id\\.with\\.dots' ).length, 1 ); + + }); + it ( 'supports nodes', function ( t ) { var eles = $('.grandparent').children (); @@ -182,6 +215,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function () }); + it ( 'check if the collection matches a selector with dots', function ( t ) { + + var child = $('.class\\.with\\.dots'); + + t.true ( child.is ( '.class\\.with\\.dots' ) ); + t.true ( child.is ( '#id\\.with\\.dots' ) ); + + }); + }); describe ( '$.fn.next', function ( it ) { @@ -214,6 +256,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function () }); + it ( 'supports selector with dots', function ( t ) { + + var child = $('.dots\\.first'); + var next = $('.class\\.with\\.dots'); + + t.deepEqual ( child.next ( '.class\\.with\\.dots' ).get (), next.get () ); + + }); + }); describe ( '$.fn.nextAll', function ( it ) {