1
1
2
- var matched , browser ,
3
- oldInit = jQuery . fn . init ,
4
- rspaceAngle = / ^ \s * < / ,
5
- rattrHash = / \[ \s * \w + \s * [ ~ | ^ $ * ] ? = \s * (? ! [ \s ' " ] ) [ ^ # \] ] * # / ,
2
+ var oldInit = jQuery . fn . init ,
3
+ rattrHash = / \[ \s * \w + \s * [ ~ | ^ $ * ] ? = \s * (? ! [ \s ' " ] ) [ ^ # \] ] * # / ;
6
4
7
- // Note: XSS check is done below after string is trimmed
8
- rquickExpr = / ^ ( [ ^ < ] * ) ( < [ \w \W ] + > ) ( [ ^ > ] * ) $ / ;
9
-
10
- // $(html) "looks like html" rule change
11
- jQuery . fn . init = function ( selector , context , rootjQuery ) {
12
- var match , ret ;
13
-
14
- if ( selector && typeof selector === "string" && ! jQuery . isPlainObject ( context ) &&
15
- ( match = rquickExpr . exec ( jQuery . trim ( selector ) ) ) && match [ 0 ] ) {
16
-
17
- // This is an HTML string according to the "old" rules; is it still?
18
- if ( ! rspaceAngle . test ( selector ) ) {
19
- migrateWarn ( "$(html) HTML strings must start with '<' character" ) ;
20
- }
21
- if ( match [ 3 ] ) {
22
- migrateWarn ( "$(html) HTML text after last tag is ignored" ) ;
23
- }
24
-
25
- // Consistently reject any HTML-like string starting with a hash (#9521)
26
- // Note that this may break jQuery 1.6.x code that otherwise would work.
27
- if ( match [ 0 ] . charAt ( 0 ) === "#" ) {
28
- migrateWarn ( "HTML string cannot start with a '#' character" ) ;
29
- jQuery . error ( "JQMIGRATE: Invalid selector string (XSS)" ) ;
30
- }
31
-
32
- // Now process using loose rules; let pre-1.8 play too
33
- if ( context && context . context ) {
34
-
35
- // JQuery object as context; parseHTML expects a DOM object
36
- context = context . context ;
37
- }
38
- if ( jQuery . parseHTML ) {
39
- return oldInit . call ( this ,
40
- jQuery . parseHTML ( match [ 2 ] , context && context . ownerDocument ||
41
- context || document , true ) , context , rootjQuery ) ;
42
- }
43
- }
5
+ jQuery . fn . init = function ( selector ) {
6
+ var args = Array . prototype . slice . call ( arguments ) ;
44
7
45
8
if ( selector === "#" ) {
46
9
47
10
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
48
11
migrateWarn ( "jQuery( '#' ) is not a valid selector" ) ;
49
- selector = [ ] ;
12
+ args [ 0 ] = selector = [ ] ;
50
13
51
14
} else if ( rattrHash . test ( selector ) ) {
52
15
@@ -55,95 +18,10 @@ jQuery.fn.init = function( selector, context, rootjQuery ) {
55
18
migrateWarn ( "Attribute selectors with '#' must be quoted: '" + selector + "'" ) ;
56
19
}
57
20
58
- ret = oldInit . apply ( this , arguments ) ;
59
-
60
- // Fill in selector and context properties so .live() works
61
- if ( selector && selector . selector !== undefined ) {
62
-
63
- // A jQuery object, copy its properties
64
- ret . selector = selector . selector ;
65
- ret . context = selector . context ;
66
-
67
- } else {
68
- ret . selector = typeof selector === "string" ? selector : "" ;
69
- if ( selector ) {
70
- ret . context = selector . nodeType ? selector : context || document ;
71
- }
72
- }
73
-
74
- return ret ;
21
+ return oldInit . apply ( this , args ) ;
75
22
} ;
76
23
jQuery . fn . init . prototype = jQuery . fn ;
77
24
78
- jQuery . uaMatch = function ( ua ) {
79
- ua = ua . toLowerCase ( ) ;
80
-
81
- var match = / ( c h r o m e ) [ \/ ] ( [ \w . ] + ) / . exec ( ua ) ||
82
- / ( w e b k i t ) [ \/ ] ( [ \w . ] + ) / . exec ( ua ) ||
83
- / ( o p e r a ) (?: .* v e r s i o n | ) [ \/ ] ( [ \w . ] + ) / . exec ( ua ) ||
84
- / ( m s i e ) ( [ \w . ] + ) / . exec ( ua ) ||
85
- ua . indexOf ( "compatible" ) < 0 && / ( m o z i l l a ) (?: .* ? r v : ( [ \w . ] + ) | ) / . exec ( ua ) ||
86
- [ ] ;
87
-
88
- return {
89
- browser : match [ 1 ] || "" ,
90
- version : match [ 2 ] || "0"
91
- } ;
92
- } ;
93
-
94
- // Don't clobber any existing jQuery.browser in case it's different
95
- if ( ! jQuery . browser ) {
96
- matched = jQuery . uaMatch ( navigator . userAgent ) ;
97
- browser = { } ;
98
-
99
- if ( matched . browser ) {
100
- browser [ matched . browser ] = true ;
101
- browser . version = matched . version ;
102
- }
103
-
104
- // Chrome is Webkit, but Webkit is also Safari.
105
- if ( browser . chrome ) {
106
- browser . webkit = true ;
107
- } else if ( browser . webkit ) {
108
- browser . safari = true ;
109
- }
110
-
111
- jQuery . browser = browser ;
112
- }
113
-
114
- // Warn if the code tries to get jQuery.browser
115
- migrateWarnProp ( jQuery , "browser" , jQuery . browser , "jQuery.browser is deprecated" ) ;
116
-
117
- // JQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
118
- jQuery . boxModel = jQuery . support . boxModel = ( document . compatMode === "CSS1Compat" ) ;
119
- migrateWarnProp ( jQuery , "boxModel" , jQuery . boxModel , "jQuery.boxModel is deprecated" ) ;
120
- migrateWarnProp (
121
- jQuery . support ,
122
- "boxModel" ,
123
- jQuery . support . boxModel , "jQuery.support.boxModel is deprecated"
124
- ) ;
125
-
126
- jQuery . sub = function ( ) {
127
- function jQuerySub ( selector , context ) {
128
- return new jQuerySub . fn . init ( selector , context ) ;
129
- }
130
- jQuery . extend ( true , jQuerySub , this ) ;
131
- jQuerySub . superclass = this ;
132
- jQuerySub . fn = jQuerySub . prototype = this ( ) ;
133
- jQuerySub . fn . constructor = jQuerySub ;
134
- jQuerySub . sub = this . sub ;
135
- jQuerySub . fn . init = function init ( selector , context ) {
136
- var instance = jQuery . fn . init . call ( this , selector , context , rootjQuerySub ) ;
137
- return instance instanceof jQuerySub ?
138
- instance :
139
- jQuerySub ( instance ) ;
140
- } ;
141
- jQuerySub . fn . init . prototype = jQuerySub . fn ;
142
- var rootjQuerySub = jQuerySub ( document ) ;
143
- migrateWarn ( "jQuery.sub() is deprecated" ) ;
144
- return jQuerySub ;
145
- } ;
146
-
147
25
// The number of elements contained in the matched element set
148
26
jQuery . fn . size = function ( ) {
149
27
migrateWarn ( "jQuery.fn.size() is deprecated; use the .length property" ) ;
0 commit comments