11import { jQueryVersionSince } from "../compareVersions.js" ;
22import { migrateWarn , migrateWarnFunc , migrateWarnProp } from "../main.js" ;
3+ import { disabledPatches } from "../disableWarnings.js" ;
34
45var findProp ,
56 class2type = { } ,
@@ -16,23 +17,26 @@ var findProp,
1617jQuery . fn . init = function ( arg1 ) {
1718 var args = Array . prototype . slice . call ( arguments ) ;
1819
19- if ( typeof arg1 === "string" && arg1 === "#" ) {
20+ if ( ! disabledPatches [ "code-TODO" ] && typeof arg1 === "string" && arg1 === "#" ) {
2021
21- // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
22- migrateWarn ( "jQuery( '#' ) is not a valid selector" ) ;
22+ // JQuery( "#" ) is a bogus ID selector, but it returned an empty set
23+ // before jQuery 3.0
24+ migrateWarn ( "code-TODO" , "jQuery( '#' ) is not a valid selector" ) ;
2325 args [ 0 ] = [ ] ;
2426 }
2527
2628 return oldInit . apply ( this , args ) ;
2729} ;
30+
2831jQuery . fn . init . prototype = jQuery . fn ;
2932
3033jQuery . find = function ( selector ) {
3134 var args = Array . prototype . slice . call ( arguments ) ;
3235
3336 // Support: PhantomJS 1.x
3437 // String#match fails to match when used with a //g RegExp, only on some strings
35- if ( typeof selector === "string" && rattrHashTest . test ( selector ) ) {
38+ if ( ! disabledPatches [ "selector-hash" ] &&
39+ typeof selector === "string" && rattrHashTest . test ( selector ) ) {
3640
3741 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
3842 // First see if qS thinks it's a valid selector, if so avoid a false positive
@@ -49,10 +53,12 @@ jQuery.find = function( selector ) {
4953 // Note that there may be false alarms if selector uses jQuery extensions
5054 try {
5155 window . document . querySelector ( selector ) ;
52- migrateWarn ( "Attribute selector with '#' must be quoted: " + args [ 0 ] ) ;
56+ migrateWarn ( "selector-hash" ,
57+ "Attribute selector with '#' must be quoted: " + args [ 0 ] ) ;
5358 args [ 0 ] = selector ;
5459 } catch ( err2 ) {
55- migrateWarn ( "Attribute selector with '#' was not fixed: " + args [ 0 ] ) ;
60+ migrateWarn ( "selector-hash" ,
61+ "Attribute selector with '#' was not fixed: " + args [ 0 ] ) ;
5662 }
5763 }
5864 }
@@ -70,24 +76,24 @@ for ( findProp in oldFind ) {
7076// The number of elements contained in the matched element set
7177migrateWarnFunc ( jQuery . fn , "size" , function ( ) {
7278 return this . length ;
73- } ,
79+ } , "size" ,
7480"jQuery.fn.size() is deprecated and removed; use the .length property" ) ;
7581
7682migrateWarnFunc ( jQuery , "parseJSON" , function ( ) {
7783 return JSON . parse . apply ( null , arguments ) ;
78- } ,
84+ } , "parse-json" ,
7985"jQuery.parseJSON is deprecated; use JSON.parse" ) ;
8086
8187migrateWarnFunc ( jQuery , "holdReady" , jQuery . holdReady ,
82- "jQuery.holdReady is deprecated" ) ;
88+ "hold-ready" , " jQuery.holdReady is deprecated" ) ;
8389
8490migrateWarnFunc ( jQuery , "unique" , jQuery . uniqueSort ,
85- "jQuery.unique is deprecated; use jQuery.uniqueSort" ) ;
91+ "unique-sort" , " jQuery.unique is deprecated; use jQuery.uniqueSort" ) ;
8692
8793// Now jQuery.expr.pseudos is the standard incantation
88- migrateWarnProp ( jQuery . expr , "filters" , jQuery . expr . pseudos ,
94+ migrateWarnProp ( jQuery . expr , "filters" , jQuery . expr . pseudos , "expr-colon" ,
8995 "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ) ;
90- migrateWarnProp ( jQuery . expr , ":" , jQuery . expr . pseudos ,
96+ migrateWarnProp ( jQuery . expr , ":" , jQuery . expr . pseudos , "expr-filters" ,
9197 "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ) ;
9298
9399// Prior to jQuery 3.1.1 there were internal refs so we don't warn there
@@ -96,18 +102,18 @@ if ( jQueryVersionSince( "3.1.1" ) ) {
96102 return text == null ?
97103 "" :
98104 ( text + "" ) . replace ( rtrim , "" ) ;
99- } ,
105+ } , "trim" ,
100106 "jQuery.trim is deprecated; use String.prototype.trim" ) ;
101107}
102108
103109// Prior to jQuery 3.2 there were internal refs so we don't warn there
104110if ( jQueryVersionSince ( "3.2.0" ) ) {
105111 migrateWarnFunc ( jQuery , "nodeName" , function ( elem , name ) {
106112 return elem . nodeName && elem . nodeName . toLowerCase ( ) === name . toLowerCase ( ) ;
107- } ,
113+ } , "node-name" ,
108114 "jQuery.nodeName is deprecated" ) ;
109115
110- migrateWarnFunc ( jQuery , "isArray" , Array . isArray ,
116+ migrateWarnFunc ( jQuery , "isArray" , Array . isArray , "is-array" ,
111117 "jQuery.isArray is deprecated; use Array.isArray"
112118 ) ;
113119}
@@ -126,7 +132,7 @@ if ( jQueryVersionSince( "3.3.0" ) ) {
126132 // ...but misinterprets leading-number strings, e.g. hex literals ("0x...")
127133 // subtraction forces infinities to NaN
128134 ! isNaN ( obj - parseFloat ( obj ) ) ;
129- } ,
135+ } , "is-numeric" ,
130136 "jQuery.isNumeric() is deprecated"
131137 ) ;
132138
@@ -146,19 +152,19 @@ if ( jQueryVersionSince( "3.3.0" ) ) {
146152 return typeof obj === "object" || typeof obj === "function" ?
147153 class2type [ Object . prototype . toString . call ( obj ) ] || "object" :
148154 typeof obj ;
149- } ,
155+ } , "type" ,
150156 "jQuery.type is deprecated" ) ;
151157
152158 migrateWarnFunc ( jQuery , "isFunction" ,
153159 function ( obj ) {
154160 return typeof obj === "function" ;
155- } ,
161+ } , "is-function" ,
156162 "jQuery.isFunction() is deprecated" ) ;
157163
158164 migrateWarnFunc ( jQuery , "isWindow" ,
159165 function ( obj ) {
160166 return obj != null && obj === obj . window ;
161- } ,
167+ } , "is-window" ,
162168 "jQuery.isWindow() is deprecated"
163169 ) ;
164170}
0 commit comments