mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Core: move jQuery.fn.nodeName to jQuery.nodeName, add tests
Ref ac9e3016
Close gh-3560
This commit is contained in:
parent
56136897f2
commit
be041e4da4
@ -30,11 +30,11 @@ jQuery.fn.extend( {
|
||||
} else {
|
||||
jQuery.ready( true );
|
||||
}
|
||||
},
|
||||
nodeName: nodeName
|
||||
}
|
||||
} );
|
||||
|
||||
jQuery.isArray = Array.isArray;
|
||||
jQuery.parseJSON = JSON.parse;
|
||||
jQuery.nodeName = nodeName;
|
||||
|
||||
} );
|
||||
|
@ -116,3 +116,51 @@ QUnit.test( "jQuery.isArray", function( assert ) {
|
||||
|
||||
assert.strictEqual( jQuery.isArray, Array.isArray, "Array.isArray equals jQuery.isArray" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.nodeName", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
|
||||
assert.strictEqual( typeof jQuery.nodeName, "function", "jQuery.nodeName is a function" );
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "div" ), "div" ),
|
||||
true,
|
||||
"Basic usage (true)"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "div" ), "span" ),
|
||||
false,
|
||||
"Basic usage (false)"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "div" ), "DIV" ),
|
||||
true,
|
||||
"Ignores case in the name parameter"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "section" ), "section" ),
|
||||
true,
|
||||
"Works on HTML5 tags (true)"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "section" ), "article" ),
|
||||
false,
|
||||
"Works on HTML5 tags (false)"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "custom-element" ), "custom-element" ),
|
||||
true,
|
||||
"Works on custom elements (true)"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
jQuery.nodeName( document.createElement( "custom-element" ), "my-element" ),
|
||||
false,
|
||||
"Works on custom elements (true)"
|
||||
);
|
||||
} );
|
||||
|
Loading…
Reference in New Issue
Block a user