mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Revert "Core: Return empty array instead of null for parseHTML("")"
This reverts commit 4116914dca
.
This commit is contained in:
parent
3748c647f3
commit
7a78019751
@ -13,8 +13,8 @@ define( [
|
||||
// defaults to document
|
||||
// keepScripts (optional): If true, will include scripts passed in the html string
|
||||
jQuery.parseHTML = function( data, context, keepScripts ) {
|
||||
if ( typeof data !== "string" ) {
|
||||
return [];
|
||||
if ( !data || typeof data !== "string" ) {
|
||||
return null;
|
||||
}
|
||||
if ( typeof context === "boolean" ) {
|
||||
keepScripts = context;
|
||||
|
@ -1471,19 +1471,14 @@ QUnit.test( "jQuery.proxy", function( assert ) {
|
||||
} );
|
||||
|
||||
QUnit.test("jQuery.parseHTML", function( assert ) {
|
||||
assert.expect( 23 );
|
||||
assert.expect( 18 );
|
||||
|
||||
var html, nodes;
|
||||
|
||||
assert.deepEqual( jQuery.parseHTML(), [], "Without arguments" );
|
||||
assert.deepEqual( jQuery.parseHTML( undefined ), [], "Undefined" );
|
||||
assert.deepEqual( jQuery.parseHTML( null ), [], "Null" );
|
||||
assert.deepEqual( jQuery.parseHTML( false ), [], "Boolean false" );
|
||||
assert.deepEqual( jQuery.parseHTML( 0 ), [], "Zero" );
|
||||
assert.deepEqual( jQuery.parseHTML( true ), [], "Boolean true" );
|
||||
assert.deepEqual( jQuery.parseHTML( 42 ), [], "Positive number" );
|
||||
assert.deepEqual( jQuery.parseHTML( "" ), [], "Empty string" );
|
||||
assert.throws( function() {
|
||||
assert.equal( jQuery.parseHTML(), null, "Nothing in, null out." );
|
||||
assert.equal( jQuery.parseHTML( null ), null, "Null in, null out." );
|
||||
assert.equal( jQuery.parseHTML( "" ), null, "Empty string in, null out." );
|
||||
throws(function() {
|
||||
jQuery.parseHTML( "<div></div>", document.getElementById("form") );
|
||||
}, "Passing an element as the context raises an exception (context should be a document)");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user