aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-07-29 22:06:18 +0200
committerGitHub <noreply@github.com>2019-07-29 22:06:18 +0200
commit2d9d6d5b476b9cd1c546592817ef8e96b32e5792 (patch)
tree8cddea99155dd643408a86172bbf25797eca4e7e /src
parent90f78b9aab9c99ff3ffcccb1db602670e9707fa0 (diff)
downloadjquery-2d9d6d5b476b9cd1c546592817ef8e96b32e5792.tar.gz
jquery-2d9d6d5b476b9cd1c546592817ef8e96b32e5792.zip
Selector: Make selector-native's isXMLDoc recognize HTML-embedded SVG
This commit also backports some jQuery.isXMLDoc tests from master so that this behavior doesn't regress. (partially cherry-picked from 79b74e043a4ee737d44a95094ff1184e40bd5b16) Closes gh-4438 Ref jquery/sizzle#378 Ref jquery/sizzle#436
Diffstat (limited to 'src')
-rw-r--r--src/selector-native.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/selector-native.js b/src/selector-native.js
index da837a004..05cd8eaeb 100644
--- a/src/selector-native.js
+++ b/src/selector-native.js
@@ -34,6 +34,7 @@ define( [
*/
var hasDuplicate, sortInput,
+ rhtmlSuffix = /HTML$/i,
sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando,
matches = documentElement.matches ||
documentElement.webkitMatchesSelector ||
@@ -200,11 +201,14 @@ jQuery.extend( {
return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) );
},
isXMLDoc: function( elem ) {
-
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = elem && ( elem.ownerDocument || elem ).documentElement;
- return documentElement ? documentElement.nodeName !== "HTML" : false;
+ var namespace = elem.namespaceURI,
+ documentElement = ( elem.ownerDocument || elem ).documentElement;
+
+ // Assume HTML when documentElement doesn't yet exist, such as inside
+ // document fragments.
+ return !rhtmlSuffix.test( namespace ||
+ documentElement && documentElement.nodeName ||
+ "HTML" );
},
expr: {
attrHandle: {},