]> source.dussan.org Git - jquery.git/commitdiff
Core: Deprecate jQuery.trim
authorShashanka Nataraj <ShashankaNataraj@users.noreply.github.com>
Thu, 22 Aug 2019 00:06:26 +0000 (05:36 +0530)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Thu, 22 Aug 2019 00:06:26 +0000 (02:06 +0200)
Fixes gh-4363
Closes gh-4461

src/core.js
src/deprecated.js
test/unit/basic.js
test/unit/core.js
test/unit/deprecated.js

index fdc32dde830425cb874ef6f89e00e8ce5f36fcfe..01f501d21077301bf6b04421d24044fabffe24a2 100644 (file)
@@ -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 ) {
index 4edefaca07187a24e83f6ed4ab4d8ff1f297b908..6ca79d514a213e5234a88464382b5f718791f8b3 100644 (file)
@@ -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 );
+};
 } );
index 8b567f1957841e0db7ff056b0b90d0f55ff4675c..79a0610ddce8fb19f8259b8b0c7c4474a34aefed 100644 (file)
@@ -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)" );
index c7532df47854839c7812937e6e0e8c5c3e194a3b..ca644fe20e3ef514b400b1904a447525a9aa59a9 100644 (file)
@@ -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();
 
index c0ebf19d61544c031f960a9640cbcde5a4126100..df9d5ffa856ad2de4fea88aba4f566e7ffee766c 100644 (file)
@@ -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" );
+} );