Core: deprecate jQuery.now

Fixes gh-2959
Close gh-3884
This commit is contained in:
Timmy Willison 2017-12-11 12:39:11 -05:00
parent 775caebd61
commit 909e0c9925
No known key found for this signature in database
GPG Key ID: 5F0C8B73EF56CE6F
10 changed files with 15 additions and 17 deletions

View File

@ -1,7 +1,5 @@
define( [
"../../core"
], function( jQuery ) {
define( function() {
"use strict";
return jQuery.now();
return Date.now();
} );

View File

@ -424,8 +424,6 @@ jQuery.extend( {
return proxy;
},
now: Date.now,
// jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist.
support: support

View File

@ -41,4 +41,6 @@ jQuery.nodeName = nodeName;
jQuery.isWindow = isWindow;
jQuery.camelCase = camelCase;
jQuery.now = Date.now;
} );

4
src/effects.js vendored
View File

@ -45,7 +45,7 @@ function createFxNow() {
window.setTimeout( function() {
fxNow = undefined;
} );
return ( fxNow = jQuery.now() );
return ( fxNow = Date.now() );
}
// Generate parameters to create a standard animation
@ -653,7 +653,7 @@ jQuery.fx.tick = function() {
i = 0,
timers = jQuery.timers;
fxNow = jQuery.now();
fxNow = Date.now();
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];

View File

@ -553,7 +553,7 @@ jQuery.Event = function( src, props ) {
}
// Create a timestamp if incoming event doesn't have one
this.timeStamp = src && src.timeStamp || jQuery.now();
this.timeStamp = src && src.timeStamp || Date.now();
// Mark it as fixed
this[ jQuery.expando ] = true;

View File

@ -19,13 +19,11 @@ QUnit.module( "animation", {
this._oldInterval = jQuery.fx.interval;
jQuery.fx.step = {};
jQuery.fx.interval = 10;
jQuery.now = Date.now;
jQuery.Animation.prefilters = [ defaultPrefilter ];
jQuery.Animation.tweeners = { "*": [ defaultTweener ] };
},
teardown: function() {
this.sandbox.restore();
jQuery.now = Date.now;
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
window.requestAnimationFrame = oldRaf;

View File

@ -190,10 +190,10 @@ QUnit.test( "globalEval execution after script injection (#7862)", function( ass
script.src = baseURL + "mock.php?action=wait&wait=2&script=1";
now = jQuery.now();
now = Date.now();
document.body.appendChild( script );
jQuery.globalEval( "var strictEvalTest = " + jQuery.now() + ";" );
jQuery.globalEval( "var strictEvalTest = " + Date.now() + ";" );
assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
} );

View File

@ -202,3 +202,9 @@ QUnit.test( "jQuery.camelCase()", function( assert ) {
assert.equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
} );
} );
QUnit.test( "jQuery.now", function( assert ) {
assert.expect( 1 );
assert.ok( typeof jQuery.now() === "number", "jQuery.now is a function" );
} );

View File

@ -19,11 +19,9 @@ QUnit.module( "effects", {
this._oldInterval = jQuery.fx.interval;
jQuery.fx.step = {};
jQuery.fx.interval = 10;
jQuery.now = Date.now;
},
teardown: function() {
this.sandbox.restore();
jQuery.now = Date.now;
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
window.requestAnimationFrame = oldRaf;

View File

@ -15,11 +15,9 @@ QUnit.module( "tween", {
this._oldInterval = jQuery.fx.interval;
jQuery.fx.step = {};
jQuery.fx.interval = 10;
jQuery.now = Date.now;
},
teardown: function() {
this.sandbox.restore();
jQuery.now = Date.now;
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
window.requestAnimationFrame = oldRaf;