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..19e30910 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:** Use a custom utility. + ### \[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.