Skip to content

Commit 6041d46

Browse files
committed
Core: Use migrateWarnProp for warning on function call, not access
Closes #212 Unit tests already were using calls, so no changes were needed there. migrateWarnFunc will be used in a lot of the 3.2 deprecations.
1 parent dc1d703 commit 6041d46

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/ajax.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ jQuery.ajax = function( ) {
66

77
// Be sure we got a jQXHR (e.g., not sync)
88
if ( jQXHR.promise ) {
9-
migrateWarnProp( jQXHR, "success", jQXHR.done,
9+
migrateWarnFunc( jQXHR, "success", jQXHR.done,
1010
"jQXHR.success is deprecated and removed" );
11-
migrateWarnProp( jQXHR, "error", jQXHR.fail,
11+
migrateWarnFunc( jQXHR, "error", jQXHR.fail,
1212
"jQXHR.error is deprecated and removed" );
13-
migrateWarnProp( jQXHR, "complete", jQXHR.always,
13+
migrateWarnFunc( jQXHR, "complete", jQXHR.always,
1414
"jQXHR.complete is deprecated and removed" );
1515
}
1616

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jQuery.isNumeric = function( val ) {
8989
return oldValue;
9090
};
9191

92-
migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
92+
migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort,
9393
"jQuery.unique is deprecated, use jQuery.uniqueSort" );
9494

9595
// Now jQuery.expr.pseudos is the standard incantation

src/migrate.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ function migrateWarnProp( obj, prop, value, msg ) {
6868
} );
6969
}
7070

71+
function migrateWarnFunc( obj, prop, newFunc, msg ) {
72+
obj[ prop ] = function() {
73+
migrateWarn( msg );
74+
return newFunc.apply( this, arguments );
75+
};
76+
}
77+
7178
if ( document.compatMode === "BackCompat" ) {
7279

7380
// JQuery has never supported or tested Quirks Mode

0 commit comments

Comments
 (0)