File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1852,6 +1852,33 @@ QUnit.test( "delegated event with intermediate DOM manipulation (#13208)", funct
18521852 jQuery ( "#anchor2" ) . trigger ( "click" ) ;
18531853} ) ;
18541854
1855+ QUnit . test ( "ignore comment nodes in event delegation (gh-2055)" , function ( assert ) {
1856+ assert . expect ( 1 ) ;
1857+
1858+ // Test if DOMNodeInserted is supported
1859+ // This is a back-up for when DOMNodeInserted support
1860+ // is eventually removed from browsers
1861+ function test ( ) {
1862+ var ret = false ;
1863+ var $fixture = jQuery ( "#qunit-fixture" ) ;
1864+ $fixture . on ( "DOMNodeInserted" , function ( ) {
1865+ ret = true ;
1866+ $fixture . off ( "DOMNodeInserted" ) ;
1867+ } ) . append ( "<div></div>" ) ;
1868+ return ret ;
1869+ }
1870+
1871+ var $foo = jQuery ( "#foo" ) . on ( "DOMNodeInserted" , "[id]" , function ( ) {
1872+ assert . ok ( true , "No error thrown on comment node" ) ;
1873+ } ) ,
1874+ $comment = jQuery ( document . createComment ( "comment" ) )
1875+ . appendTo ( $foo . find ( "#sap" ) ) ;
1876+
1877+ if ( ! test ( ) ) {
1878+ fireNative ( $comment [ 0 ] , "DOMNodeInserted" ) ;
1879+ }
1880+ } ) ;
1881+
18551882QUnit . test ( "stopPropagation() stops directly-bound events on delegated target" , function ( assert ) {
18561883 assert . expect ( 1 ) ;
18571884
You can’t perform that action at this time.
0 commit comments