mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: deprecate jQuery.now
Fixes gh-2959 Close gh-3884
This commit is contained in:
parent
775caebd61
commit
909e0c9925
@ -1,7 +1,5 @@
|
|||||||
define( [
|
define( function() {
|
||||||
"../../core"
|
|
||||||
], function( jQuery ) {
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return jQuery.now();
|
return Date.now();
|
||||||
} );
|
} );
|
||||||
|
@ -424,8 +424,6 @@ jQuery.extend( {
|
|||||||
return proxy;
|
return proxy;
|
||||||
},
|
},
|
||||||
|
|
||||||
now: Date.now,
|
|
||||||
|
|
||||||
// jQuery.support is not used in Core but other projects attach their
|
// jQuery.support is not used in Core but other projects attach their
|
||||||
// properties to it so it needs to exist.
|
// properties to it so it needs to exist.
|
||||||
support: support
|
support: support
|
||||||
|
@ -41,4 +41,6 @@ jQuery.nodeName = nodeName;
|
|||||||
jQuery.isWindow = isWindow;
|
jQuery.isWindow = isWindow;
|
||||||
jQuery.camelCase = camelCase;
|
jQuery.camelCase = camelCase;
|
||||||
|
|
||||||
|
jQuery.now = Date.now;
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
4
src/effects.js
vendored
4
src/effects.js
vendored
@ -45,7 +45,7 @@ function createFxNow() {
|
|||||||
window.setTimeout( function() {
|
window.setTimeout( function() {
|
||||||
fxNow = undefined;
|
fxNow = undefined;
|
||||||
} );
|
} );
|
||||||
return ( fxNow = jQuery.now() );
|
return ( fxNow = Date.now() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate parameters to create a standard animation
|
// Generate parameters to create a standard animation
|
||||||
@ -653,7 +653,7 @@ jQuery.fx.tick = function() {
|
|||||||
i = 0,
|
i = 0,
|
||||||
timers = jQuery.timers;
|
timers = jQuery.timers;
|
||||||
|
|
||||||
fxNow = jQuery.now();
|
fxNow = Date.now();
|
||||||
|
|
||||||
for ( ; i < timers.length; i++ ) {
|
for ( ; i < timers.length; i++ ) {
|
||||||
timer = timers[ i ];
|
timer = timers[ i ];
|
||||||
|
@ -553,7 +553,7 @@ jQuery.Event = function( src, props ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a timestamp if incoming event doesn't have one
|
// 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
|
// Mark it as fixed
|
||||||
this[ jQuery.expando ] = true;
|
this[ jQuery.expando ] = true;
|
||||||
|
@ -19,13 +19,11 @@ QUnit.module( "animation", {
|
|||||||
this._oldInterval = jQuery.fx.interval;
|
this._oldInterval = jQuery.fx.interval;
|
||||||
jQuery.fx.step = {};
|
jQuery.fx.step = {};
|
||||||
jQuery.fx.interval = 10;
|
jQuery.fx.interval = 10;
|
||||||
jQuery.now = Date.now;
|
|
||||||
jQuery.Animation.prefilters = [ defaultPrefilter ];
|
jQuery.Animation.prefilters = [ defaultPrefilter ];
|
||||||
jQuery.Animation.tweeners = { "*": [ defaultTweener ] };
|
jQuery.Animation.tweeners = { "*": [ defaultTweener ] };
|
||||||
},
|
},
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
this.sandbox.restore();
|
this.sandbox.restore();
|
||||||
jQuery.now = Date.now;
|
|
||||||
jQuery.fx.stop();
|
jQuery.fx.stop();
|
||||||
jQuery.fx.interval = this._oldInterval;
|
jQuery.fx.interval = this._oldInterval;
|
||||||
window.requestAnimationFrame = oldRaf;
|
window.requestAnimationFrame = oldRaf;
|
||||||
|
@ -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";
|
script.src = baseURL + "mock.php?action=wait&wait=2&script=1";
|
||||||
|
|
||||||
now = jQuery.now();
|
now = Date.now();
|
||||||
document.body.appendChild( script );
|
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" );
|
assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -202,3 +202,9 @@ QUnit.test( "jQuery.camelCase()", function( assert ) {
|
|||||||
assert.equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
|
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" );
|
||||||
|
} );
|
||||||
|
2
test/unit/effects.js
vendored
2
test/unit/effects.js
vendored
@ -19,11 +19,9 @@ QUnit.module( "effects", {
|
|||||||
this._oldInterval = jQuery.fx.interval;
|
this._oldInterval = jQuery.fx.interval;
|
||||||
jQuery.fx.step = {};
|
jQuery.fx.step = {};
|
||||||
jQuery.fx.interval = 10;
|
jQuery.fx.interval = 10;
|
||||||
jQuery.now = Date.now;
|
|
||||||
},
|
},
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
this.sandbox.restore();
|
this.sandbox.restore();
|
||||||
jQuery.now = Date.now;
|
|
||||||
jQuery.fx.stop();
|
jQuery.fx.stop();
|
||||||
jQuery.fx.interval = this._oldInterval;
|
jQuery.fx.interval = this._oldInterval;
|
||||||
window.requestAnimationFrame = oldRaf;
|
window.requestAnimationFrame = oldRaf;
|
||||||
|
@ -15,11 +15,9 @@ QUnit.module( "tween", {
|
|||||||
this._oldInterval = jQuery.fx.interval;
|
this._oldInterval = jQuery.fx.interval;
|
||||||
jQuery.fx.step = {};
|
jQuery.fx.step = {};
|
||||||
jQuery.fx.interval = 10;
|
jQuery.fx.interval = 10;
|
||||||
jQuery.now = Date.now;
|
|
||||||
},
|
},
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
this.sandbox.restore();
|
this.sandbox.restore();
|
||||||
jQuery.now = Date.now;
|
|
||||||
jQuery.fx.stop();
|
jQuery.fx.stop();
|
||||||
jQuery.fx.interval = this._oldInterval;
|
jQuery.fx.interval = this._oldInterval;
|
||||||
window.requestAnimationFrame = oldRaf;
|
window.requestAnimationFrame = oldRaf;
|
||||||
|
Loading…
Reference in New Issue
Block a user