From d78cb2320657c3f6eca2a6fffc060bd071de149e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Fri, 12 Sep 2025 16:13:43 +0200 Subject: [PATCH 1/2] Core: Warn against jQuery.now & jQuery.camelCase These APIs have been deprecated in jQuery 3.3. Fixes gh-594 Fixes gh-595 --- src/jquery/core.js | 8 ++++++++ test/unit/jquery/core.js | 29 +++++++++++++++++++++++++++++ warnings.md | 12 ++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/jquery/core.js b/src/jquery/core.js index aca64fbf..2f9839c8 100644 --- a/src/jquery/core.js +++ b/src/jquery/core.js @@ -114,6 +114,14 @@ if ( jQueryVersionSince( "3.3.0" ) ) { "jQuery.isWindow() is deprecated" ); + migratePatchAndWarnFunc( jQuery, "now", Date.now, "now", + "jQuery.now() is deprecated; use Date.now()" + ); + + migratePatchAndWarnFunc( jQuery, "camelCase", jQuery.camelCase, "camelCase", + "jQuery.camelCase() is deprecated" + ); + // Bind a function to a context, optionally partially applying any // arguments. // jQuery.proxy is deprecated to promote standards (specifically Function#bind) diff --git a/test/unit/jquery/core.js b/test/unit/jquery/core.js index d980059e..e67d723a 100644 --- a/test/unit/jquery/core.js +++ b/test/unit/jquery/core.js @@ -199,6 +199,35 @@ QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.isWindow", fun } ); } ); +QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.now", function( assert ) { + assert.expect( 2 ); + + expectWarning( assert, "now", 1, function() { + assert.ok( typeof jQuery.now() === "number", "jQuery.now is a function" ); + } ); +} ); + +QUnit[ jQueryVersionSince( "3.3.0" ) ? "test" : "skip" ]( "jQuery.camelCase()", function( assert ) { + + var tests = { + "foo-bar": "fooBar", + "foo-bar-baz": "fooBarBaz", + "girl-u-want": "girlUWant", + "the-4th-dimension": "the-4thDimension", + "-o-tannenbaum": "OTannenbaum", + "-moz-illa": "MozIlla", + "-ms-take": "msTake" + }; + + assert.expect( 8 ); + + expectWarning( assert, "now", 7, function() { + jQuery.each( tests, function( key, val ) { + assert.equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val ); + } ); + } ); +} ); + QUnit.test( "jQuery.unique", function( assert ) { assert.expect( 2 ); diff --git a/warnings.md b/warnings.md index 78cc9892..67f6515d 100644 --- a/warnings.md +++ b/warnings.md @@ -99,6 +99,18 @@ This is _not_ a warning, but a console log message the plugin shows when it firs **Solution**: Replace any use of `.size()` with `.length`. +### \[now\] JQMIGRATE: jQuery.now() is deprecated; use Date.now + +**Cause:** The `jQuery.now()` method was a simple alias for `Date.now()`, which is now supported in all browsers supported by jQuery 3.0. + +**Solution:** Replace any calls to `jQuery.now()` with `Date.now()`. + +### \[camelCase\] JQMIGRATE: jQuery.camelCase() is deprecated + +**Cause:** The `jQuery.camelCase()` method was a utility to convert dashed strings like `"background-color"` into camel-cased strings like `"backgroundColor"`. This method was never documented and is now deprecated. + +**Solution:** If you need this functionality, you can implement it yourself. + ### \[data-camelCase\] JQMIGRATE: jQuery.data() always sets/gets camelCased names **Cause:** The page is attempting to set or get a jQuery data item using kebab case, e.g. `my-data`, when a `my-data` item has been set directly on the jQuery data object. jQuery 3.0 always exclusively uses camel case, e.g., `myData`, when it accesses data items via the `.data()` API and does not find kebab case data in that object. From 46ecc0b79a997542cfddf0a44ad74c83cdd667dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= Date: Sat, 13 Sep 2025 00:10:07 +0200 Subject: [PATCH 2/2] Update warnings.md Co-authored-by: Timmy Willison --- warnings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/warnings.md b/warnings.md index 67f6515d..19e30910 100644 --- a/warnings.md +++ b/warnings.md @@ -109,7 +109,7 @@ This is _not_ a warning, but a console log message the plugin shows when it firs **Cause:** The `jQuery.camelCase()` method was a utility to convert dashed strings like `"background-color"` into camel-cased strings like `"backgroundColor"`. This method was never documented and is now deprecated. -**Solution:** If you need this functionality, you can implement it yourself. +**Solution:** Use a custom utility. ### \[data-camelCase\] JQMIGRATE: jQuery.data() always sets/gets camelCased names