Skip to content

Commit f822d09

Browse files
committed
Selector: Drop support for EdgeHTML (i.e. non-Chromium Microsoft Edge)
Also, restrict some workarounds that were applied unconditionally in all browsers to run only in IE now. This slightly increases the size but reduces the performance burden on modern browsers that don't need the workarounds. Also, clean up some comments & remove some obsolete workarounds. Fixes jquerygh-4568
1 parent 437f389 commit f822d09

24 files changed

+108
-232
lines changed

src/ajax.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ jQuery.extend( {
542542
if ( s.crossDomain == null ) {
543543
urlAnchor = document.createElement( "a" );
544544

545-
// Support: IE <=8 - 11+, Edge 12 - 17 only
545+
// Support: IE <=8 - 11+
546546
// IE throws exception on accessing the href property if url is malformed,
547547
// e.g. http://example.com:80x/
548548
try {

src/attributes/prop.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ jQuery.extend( {
6969

7070
if (
7171
rfocusable.test( elem.nodeName ) ||
72-
rclickable.test( elem.nodeName ) &&
73-
elem.href
72+
73+
// href-less anchors `tabIndex` property value is `0` and the `tabindex`
74+
// attribute value: `null`. We want `-1`.
75+
rclickable.test( elem.nodeName ) && elem.href
7476
) {
7577
return 0;
7678
}

src/core.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,7 @@ jQuery.extend( {
274274
ret += jQuery.text( node );
275275
}
276276
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
277-
278-
// Use textContent for elements
279-
// innerText usage removed for consistency of new lines (jQuery #11153)
280-
if ( typeof elem.textContent === "string" ) {
281-
return elem.textContent;
282-
} else {
283-
284-
// Traverse its children
285-
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
286-
ret += jQuery.text( elem );
287-
}
288-
}
277+
return elem.textContent;
289278
} else if ( nodeType === 3 || nodeType === 4 ) {
290279
return elem.nodeValue;
291280
}

src/core/DOMEval.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ function DOMEval( code, node, doc ) {
1717
if ( node ) {
1818
for ( i in preservedScriptAttributes ) {
1919

20-
// Support: Firefox <=64 - 66+, Edge <=18+
21-
// Some browsers don't support the "nonce" property on scripts.
20+
// Support: Firefox <=64 - 66+
21+
// Firefox doesn't support the "nonce" property on scripts.
2222
// On the other hand, just using `getAttribute` is not enough as
2323
// the `nonce` attribute is reset to an empty string whenever it
2424
// becomes browsing-context connected.
2525
// See https://github.com/whatwg/html/issues/2369
2626
// See https://html.spec.whatwg.org/#nonce-attributes
27+
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1389421
2728
// The `node.getAttribute` check was added for the sake of
2829
// `jQuery.globalEval` so that it can fake a nonce-containing node
2930
// via an object.

src/core/isAttached.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import documentElement from "../var/documentElement.js";
33

44
import "../selector/contains.js"; // jQuery.contains
55

6-
var isAttached = function( elem ) {
7-
return jQuery.contains( elem.ownerDocument, elem );
8-
},
9-
composed = { composed: true };
6+
var composed = { composed: true },
107

11-
// Support: IE 9 - 11+, Edge 12 - 18+
12-
// Check attachment across shadow DOM boundaries when possible (gh-3504)
13-
if ( documentElement.getRootNode ) {
14-
isAttached = function( elem ) {
15-
return jQuery.contains( elem.ownerDocument, elem ) ||
16-
elem.getRootNode( composed ) === elem.ownerDocument;
17-
};
18-
}
8+
// Support: IE 9 - 11+
9+
// Check attachment across shadow DOM boundaries when possible (gh-3504).
10+
// Provide a fallback for browsers without Shadow DOM v1 support.
11+
isAttached = documentElement.getRootNode ?
12+
function( elem ) {
13+
return jQuery.contains( elem.ownerDocument, elem ) ||
14+
elem.getRootNode( composed ) === elem.ownerDocument;
15+
} :
16+
function( elem ) {
17+
return jQuery.contains( elem.ownerDocument, elem );
18+
};
1919

2020
export default isAttached;

src/css.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import getStyles from "./css/var/getStyles.js";
1111
import swap from "./css/var/swap.js";
1212
import curCSS from "./css/curCSS.js";
1313
import adjustCSS from "./css/adjustCSS.js";
14-
import support from "./css/support.js";
1514
import finalPropName from "./css/finalPropName.js";
1615

1716
import "./core/init.js";
@@ -135,15 +134,18 @@ function getWidthOrHeight( elem, dimension, extra ) {
135134
}
136135

137136

138-
// Support: IE 9 - 11+
139-
// Use offsetWidth/offsetHeight for when box sizing is unreliable.
140-
// In those cases, the computed value can be trusted to be border-box.
141-
if ( ( isIE && isBorderBox ||
137+
if ( ( isIE && (
142138

143-
// Support: IE 10 - 11+, Edge 15 - 18+
144-
// IE/Edge misreport `getComputedStyle` of table rows with width/height
145-
// set in CSS while `offset*` properties report correct values.
146-
!support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
139+
// Support: IE 9 - 11+
140+
// Use offsetWidth/offsetHeight for when box sizing is unreliable.
141+
// In those cases, the computed value can be trusted to be border-box.
142+
isBorderBox ||
143+
144+
// Support: IE 10 - 11+
145+
// IE misreports `getComputedStyle` of table rows with width/height
146+
// set in CSS while `offset*` properties report correct values.
147+
nodeName( elem, "tr" )
148+
) ||
147149

148150
// Fall back to offsetWidth/offsetHeight when value is "auto"
149151
// This happens for inline elements with no explicit setting (gh-3571)

src/css/cssCamelCase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var rmsPrefix = /^-ms-/;
55

66
// Convert dashed to camelCase, handle vendor prefixes.
77
// Used by the css & effects modules.
8-
// Support: IE <=9 - 11+, Edge 12 - 18+
8+
// Support: IE <=9 - 11+
99
// Microsoft forgot to hump their vendor prefix (#9572)
1010
function cssCamelCase( string ) {
1111
return camelCase( string.replace( rmsPrefix, "ms-" ) );

src/css/support.js

-34
This file was deleted.

src/effects.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ function defaultPrefilter( elem, props, opts ) {
143143
// Restrict "overflow" and "display" styles during box animations
144144
if ( isBox && elem.nodeType === 1 ) {
145145

146-
// Support: IE <=9 - 11+, Edge 12 - 18+
146+
// Support: IE <=9 - 11+
147147
// Record all 3 overflow attributes because IE does not infer the shorthand
148-
// from identically-valued overflowX and overflowY and Edge just mirrors
149-
// the overflowX value there.
148+
// from identically-valued overflowX and overflowY.
150149
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
151150

152151
// Identify a display type, preferring old show/hide data over the CSS cascade

src/manipulation.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ var
2626
// See https://github.com/eslint/eslint/issues/3229
2727
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
2828

29-
// Support: IE <=10 - 11+, Edge 12 - 13 only
30-
// In IE/Edge using regex groups here causes severe slowdowns.
29+
// Support: IE <=10 - 11+
30+
// In IE using regex groups here causes severe slowdowns.
3131
// See https://connect.microsoft.com/IE/feedback/details/1736512/
3232
rnoInnerhtml = /<script|<style|<link/i,
3333

src/selector.js

+18-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import pop from "./var/pop.js";
77
import push from "./var/push.js";
88
import whitespace from "./selector/var/whitespace.js";
99
import rbuggyQSA from "./selector/rbuggyQSA.js";
10-
import support from "./selector/support.js";
10+
import isIE from "./var/isIE.js";
1111

1212
// The following utils are attached directly to the jQuery object.
1313
import "./selector/contains.js";
@@ -131,9 +131,9 @@ var i,
131131
},
132132

133133
// Used for iframes; see `setDocument`.
134-
// Support: IE 9 - 11+, Edge 12 - 18+
134+
// Support: IE 9 - 11+
135135
// Removing the function wrapper causes a "Permission Denied"
136-
// error in IE/Edge.
136+
// error in IE.
137137
unloadHandler = function() {
138138
setDocument();
139139
},
@@ -150,7 +150,7 @@ function selectorError( msg ) {
150150
}
151151

152152
function find( selector, context, results, seed ) {
153-
var m, i, elem, nid, match, groups, newSelector,
153+
var m, i, elem, nid, match, groups, newSelector, canUseScope,
154154
newContext = context && context.ownerDocument,
155155

156156
// nodeType defaults to 9, since context defaults to document
@@ -231,9 +231,10 @@ function find( selector, context, results, seed ) {
231231

232232
// We can use :scope instead of the ID hack if the browser
233233
// supports it & if we're not changing the context.
234-
if ( newContext !== context || !support.scope ) {
234+
canUseScope = newContext === context && !isIE;
235235

236-
// Capture the context ID, setting it first if necessary
236+
// Capture the context ID, setting it first if necessary
237+
if ( !canUseScope ) {
237238
if ( ( nid = context.getAttribute( "id" ) ) ) {
238239
nid = jQuery.escapeSelector( nid );
239240
} else {
@@ -360,7 +361,6 @@ function createDisabledPseudo( disabled ) {
360361
return elem.isDisabled === disabled ||
361362

362363
// Where there is no isDisabled, check manually
363-
/* jshint -W018 */
364364
elem.isDisabled !== !disabled &&
365365
inDisabledFieldset( elem ) === disabled;
366366
}
@@ -419,8 +419,8 @@ function setDocument( node ) {
419419
doc = node ? node.ownerDocument || node : preferredDoc;
420420

421421
// Return early if doc is invalid or already selected
422-
// Support: IE 11+, Edge 17 - 18+
423-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
422+
// Support: IE 11+
423+
// IE sometimes throws a "Permission denied" error when strict-comparing
424424
// two documents; shallow comparisons work.
425425
// eslint-disable-next-line eqeqeq
426426
if ( doc == document || doc.nodeType !== 9 ) {
@@ -432,16 +432,14 @@ function setDocument( node ) {
432432
documentElement = document.documentElement;
433433
documentIsHTML = !jQuery.isXMLDoc( document );
434434

435-
// Support: IE 9 - 11+, Edge 12 - 18+
435+
// Support: IE 9 - 11+
436436
// Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
437-
// Support: IE 11+, Edge 17 - 18+
438-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
437+
// Support: IE 11+
438+
// IE sometimes throws a "Permission denied" error when strict-comparing
439439
// two documents; shallow comparisons work.
440440
// eslint-disable-next-line eqeqeq
441-
if ( preferredDoc != document &&
441+
if ( isIE && preferredDoc != document &&
442442
( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
443-
444-
// Support: IE 9 - 11+, Edge 12 - 18+
445443
subWindow.addEventListener( "unload", unloadHandler );
446444
}
447445
}
@@ -926,7 +924,7 @@ Expr = jQuery.expr = {
926924
// Accessing the selectedIndex property
927925
// forces the browser to treat the default option as
928926
// selected when in an optgroup.
929-
if ( elem.parentNode ) {
927+
if ( isIE && elem.parentNode ) {
930928
// eslint-disable-next-line no-unused-expressions
931929
elem.parentNode.selectedIndex;
932930
}
@@ -1410,8 +1408,8 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
14101408

14111409
if ( outermost ) {
14121410

1413-
// Support: IE 11+, Edge 17 - 18+
1414-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1411+
// Support: IE 11+
1412+
// IE sometimes throws a "Permission denied" error when strict-comparing
14151413
// two documents; shallow comparisons work.
14161414
// eslint-disable-next-line eqeqeq
14171415
outermostContext = context == document || context || outermost;
@@ -1422,8 +1420,8 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
14221420
if ( byElement && elem ) {
14231421
j = 0;
14241422

1425-
// Support: IE 11+, Edge 17 - 18+
1426-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1423+
// Support: IE 11+
1424+
// IE sometimes throws a "Permission denied" error when strict-comparing
14271425
// two documents; shallow comparisons work.
14281426
// eslint-disable-next-line eqeqeq
14291427
if ( !context && elem.ownerDocument != document ) {

src/selector/rbuggyQSA.js

+11-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
import document from "../var/document.js";
21
import isIE from "../var/isIE.js";
32
import whitespace from "./var/whitespace.js";
43

5-
var rbuggyQSA = [],
6-
testEl = document.createElement( "div" ),
7-
input = document.createElement( "input" );
4+
var rbuggyQSA = isIE && new RegExp(
85

9-
// Support: IE 9 - 11+
10-
// IE's :disabled selector does not pick up the children of disabled fieldsets
11-
if ( isIE ) {
12-
rbuggyQSA.push( ":enabled", ":disabled" );
13-
}
6+
// Support: IE 9 - 11+
7+
// IE's :disabled selector does not pick up the children of disabled fieldsets
8+
":enabled|:disabled|" +
149

15-
// Support: IE 11+, Edge 15 - 18+
16-
// IE 11/Edge don't find elements on a `[name='']` query in some cases.
17-
// Adding a temporary attribute to the document before the selection works
18-
// around the issue.
19-
// Interestingly, IE 10 & older don't seem to have the issue.
20-
input.setAttribute( "name", "" );
21-
testEl.appendChild( input );
22-
if ( !testEl.querySelectorAll( "[name='']" ).length ) {
23-
rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
24-
whitespace + "*(?:''|\"\")" );
25-
}
10+
// Support: IE 11+
11+
// IE 11 doesn't find elements on a `[name='']` query in some cases.
12+
// Adding a temporary attribute to the document before the selection works
13+
// around the issue.
14+
"\\[" + whitespace + "*name" + whitespace + "*=" +
15+
whitespace + "*(?:''|\"\")"
2616

27-
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
17+
);
2818

2919
export default rbuggyQSA;

src/selector/support.js

-11
This file was deleted.

src/selector/uniqueSort.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function sortOrder( a, b ) {
2020
}
2121

2222
// Calculate position if both inputs belong to the same document
23-
// Support: IE 11+, Edge 17 - 18+
24-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
23+
// Support: IE 11+
24+
// IE sometimes throws a "Permission denied" error when strict-comparing
2525
// two documents; shallow comparisons work.
2626
// eslint-disable-next-line eqeqeq
2727
compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
@@ -34,17 +34,17 @@ function sortOrder( a, b ) {
3434
if ( compare & 1 ) {
3535

3636
// Choose the first element that is related to the document
37-
// Support: IE 11+, Edge 17 - 18+
38-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
37+
// Support: IE 11+
38+
// IE sometimes throws a "Permission denied" error when strict-comparing
3939
// two documents; shallow comparisons work.
4040
// eslint-disable-next-line eqeqeq
4141
if ( a == document || a.ownerDocument == document &&
4242
jQuery.contains( document, a ) ) {
4343
return -1;
4444
}
4545

46-
// Support: IE 11+, Edge 17 - 18+
47-
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
46+
// Support: IE 11+
47+
// IE sometimes throws a "Permission denied" error when strict-comparing
4848
// two documents; shallow comparisons work.
4949
// eslint-disable-next-line eqeqeq
5050
if ( b == document || b.ownerDocument == document &&

0 commit comments

Comments
 (0)