Skip to content

Commit 750d071

Browse files
committed
Core: Remove workarounds for APIs dropped before 3.0
Fixes jquery#152
1 parent 39fa123 commit 750d071

18 files changed

+223
-2194
lines changed

Gruntfile.js

-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ module.exports = function( grunt ) {
2121
"src/intro.js",
2222
"src/version.js",
2323
"src/migrate.js",
24-
"src/attributes.js",
2524
"src/core.js",
2625
"src/css.js",
27-
"src/data.js",
28-
"src/manipulation.js",
2926
"src/effects.js",
3027
"src/event.js",
3128
"src/traversing.js",

src/attributes.js

-119
This file was deleted.

src/core.js

+6-128
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,15 @@
11

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'"])[^#\]]*#/;
64

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 );
447

458
if ( selector === "#" ) {
469

4710
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
4811
migrateWarn( "jQuery( '#' ) is not a valid selector" );
49-
selector = [];
12+
args[ 0 ] = selector = [];
5013

5114
} else if ( rattrHash.test( selector ) ) {
5215

@@ -55,95 +18,10 @@ jQuery.fn.init = function( selector, context, rootjQuery ) {
5518
migrateWarn( "Attribute selectors with '#' must be quoted: '" + selector + "'" );
5619
}
5720

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 );
7522
};
7623
jQuery.fn.init.prototype = jQuery.fn;
7724

78-
jQuery.uaMatch = function( ua ) {
79-
ua = ua.toLowerCase();
80-
81-
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
82-
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
83-
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
84-
/(msie) ([\w.]+)/.exec( ua ) ||
85-
ua.indexOf( "compatible" ) < 0 && /(mozilla)(?:.*? rv:([\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-
14725
// The number of elements contained in the matched element set
14826
jQuery.fn.size = function() {
14927
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );

src/data.js

-18
This file was deleted.

0 commit comments

Comments
 (0)