🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes #4363
  • Loading branch information
ShashankaNataraj committed Aug 19, 2019
commit 38f078e22959e3c79c94e61b2b9d1eb13021181f
6 changes: 1 addition & 5 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ define( [
"./var/hasOwn",
"./var/fnToString",
"./var/ObjectFunctionString",
"./var/trim",
"./var/support",
"./var/isWindow",
"./core/DOMEval",
"./core/toType"
], function( arr, getProto, slice, concat, push, indexOf,
class2type, toString, hasOwn, fnToString, ObjectFunctionString,
trim, support, isWindow, DOMEval, toType ) {
support, isWindow, DOMEval, toType ) {

"use strict";

Expand Down Expand Up @@ -298,9 +297,6 @@ jQuery.extend( {
return ret;
},

trim: function( text ) {
return text == null ? "" : trim.call( text );
},

// results is for internal usage only
makeArray: function( arr, results ) {
Expand Down
8 changes: 6 additions & 2 deletions src/deprecated.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
define( [
"./core",
"./var/slice",

"./var/trim",
"./event/alias"
], function( jQuery, slice ) {
], function( jQuery, trim, slice ) {

"use strict";

Expand Down Expand Up @@ -66,4 +66,8 @@ jQuery.holdReady = function( hold ) {
jQuery.ready( true );
}
};

jQuery.trim = function( text ) {
return text == null ? "" : trim.call( text );
};
} );
22 changes: 0 additions & 22 deletions test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,6 @@ QUnit.test( "noConflict", function( assert ) {
window[ "jQuery" ] = jQuery = $$;
} );

QUnit.test( "trim", function( assert ) {
assert.expect( 13 );

var nbsp = String.fromCharCode( 160 );

assert.equal( jQuery.trim( "hello " ), "hello", "trailing space" );
assert.equal( jQuery.trim( " hello" ), "hello", "leading space" );
assert.equal( jQuery.trim( " hello " ), "hello", "space on both sides" );
assert.equal( jQuery.trim( " " + nbsp + "hello " + nbsp + " " ), "hello", " " );

assert.equal( jQuery.trim(), "", "Nothing in." );
assert.equal( jQuery.trim( undefined ), "", "Undefined" );
assert.equal( jQuery.trim( null ), "", "Null" );
assert.equal( jQuery.trim( 5 ), "5", "Number" );
assert.equal( jQuery.trim( false ), "false", "Boolean" );

assert.equal( jQuery.trim( " " ), "", "space should be trimmed" );
assert.equal( jQuery.trim( "ipad\xA0" ), "ipad", "nbsp should be trimmed" );
assert.equal( jQuery.trim( "\uFEFF" ), "", "zwsp should be trimmed" );
assert.equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" );
} );

QUnit.test( "isPlainObject", function( assert ) {
var done = assert.async();

Expand Down
22 changes: 22 additions & 0 deletions test/unit/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,25 @@ QUnit.test( "jQuery.proxy", function( assert ) {
cb = jQuery.proxy( fn, null, "arg1", "arg2" );
cb.call( thisObject, "arg3" );
} );

QUnit.test( "trim", function( assert ) {
assert.expect( 13 );

var nbsp = String.fromCharCode( 160 );

assert.equal( jQuery.trim( "hello " ), "hello", "trailing space" );
assert.equal( jQuery.trim( " hello" ), "hello", "leading space" );
assert.equal( jQuery.trim( " hello " ), "hello", "space on both sides" );
assert.equal( jQuery.trim( " " + nbsp + "hello " + nbsp + " " ), "hello", " " );

assert.equal( jQuery.trim(), "", "Nothing in." );
assert.equal( jQuery.trim( undefined ), "", "Undefined" );
assert.equal( jQuery.trim( null ), "", "Null" );
assert.equal( jQuery.trim( 5 ), "5", "Number" );
assert.equal( jQuery.trim( false ), "false", "Boolean" );

assert.equal( jQuery.trim( " " ), "", "space should be trimmed" );
assert.equal( jQuery.trim( "ipad\xA0" ), "ipad", "nbsp should be trimmed" );
assert.equal( jQuery.trim( "\uFEFF" ), "", "zwsp should be trimmed" );
assert.equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" );
} );