aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShashanka Nataraj <ShashankaNataraj@users.noreply.github.com>2019-08-22 05:36:26 +0530
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-08-22 02:06:26 +0200
commit5ea5946094784f68437ef26d463dfcfbbbaff1f6 (patch)
tree158256fb9ebf2d69904db439d9f0e9d4a5a81d56
parentac5f7cd8e29ecc7cdf21c13199be5472375ffa0e (diff)
downloadjquery-5ea5946094784f68437ef26d463dfcfbbbaff1f6.tar.gz
jquery-5ea5946094784f68437ef26d463dfcfbbbaff1f6.zip
Core: Deprecate jQuery.trim
Fixes gh-4363 Closes gh-4461
-rw-r--r--src/core.js6
-rw-r--r--src/deprecated.js8
-rw-r--r--test/unit/basic.js3
-rw-r--r--test/unit/core.js22
-rw-r--r--test/unit/deprecated.js22
5 files changed, 30 insertions, 31 deletions
diff --git a/src/core.js b/src/core.js
index fdc32dde8..01f501d21 100644
--- a/src/core.js
+++ b/src/core.js
@@ -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";
@@ -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 ) {
diff --git a/src/deprecated.js b/src/deprecated.js
index 4edefaca0..6ca79d514 100644
--- a/src/deprecated.js
+++ b/src/deprecated.js
@@ -1,9 +1,9 @@
define( [
"./core",
"./var/slice",
-
+ "./var/trim",
"./event/alias"
-], function( jQuery, slice ) {
+], function( jQuery, trim, slice ) {
"use strict";
@@ -66,4 +66,8 @@ jQuery.holdReady = function( hold ) {
jQuery.ready( true );
}
};
+
+jQuery.trim = function( text ) {
+ return text == null ? "" : trim.call( text );
+};
} );
diff --git a/test/unit/basic.js b/test/unit/basic.js
index 8b567f195..79a0610dd 100644
--- a/test/unit/basic.js
+++ b/test/unit/basic.js
@@ -76,12 +76,11 @@ QUnit.test( "show/hide", function( assert ) {
}
QUnit.test( "core", function( assert ) {
- assert.expect( 18 );
+ assert.expect( 17 );
var elem = jQuery( "<div></div><span></span>" );
assert.strictEqual( elem.length, 2, "Correct number of elements" );
- assert.strictEqual( jQuery.trim( " hello " ), "hello", "jQuery.trim" );
assert.ok( jQuery.isPlainObject( { "a": 2 } ), "jQuery.isPlainObject(object)" );
assert.ok( !jQuery.isPlainObject( "foo" ), "jQuery.isPlainObject(String)" );
diff --git a/test/unit/core.js b/test/unit/core.js
index c7532df47..ca644fe20 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -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", "&nbsp;" );
-
- 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();
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index c0ebf19d6..df9d5ffa8 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -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", "&nbsp;" );
+
+ 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" );
+} );