mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: drop the document.implementation.createHTMLDocument usage
The document.implementation.createHTMLDocument("") method creates inert documents which is good but using it has introduced issues around anchor elements href property not resolving according to the current document. Because of that, this patch is getting backed out on 1.x/2.x branches. (cherry-picked fromc5c3073531
) Refscfe468f29c
Refs gh-1505 Fixes gh-2941
This commit is contained in:
parent
ed94387247
commit
6403cf614f
@ -2,11 +2,8 @@ define( [
|
|||||||
"../core",
|
"../core",
|
||||||
"../var/document",
|
"../var/document",
|
||||||
"./var/rsingleTag",
|
"./var/rsingleTag",
|
||||||
"../manipulation/buildFragment",
|
"../manipulation/buildFragment"
|
||||||
|
], function( jQuery, document, rsingleTag, buildFragment ) {
|
||||||
// This is the only module that needs core/support
|
|
||||||
"./support"
|
|
||||||
], function( jQuery, document, rsingleTag, buildFragment, support ) {
|
|
||||||
|
|
||||||
// data: string of html
|
// data: string of html
|
||||||
// context (optional): If specified, the fragment will be created in this context,
|
// context (optional): If specified, the fragment will be created in this context,
|
||||||
@ -20,12 +17,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
|
|||||||
keepScripts = context;
|
keepScripts = context;
|
||||||
context = false;
|
context = false;
|
||||||
}
|
}
|
||||||
|
context = context || document;
|
||||||
// document.implementation stops scripts or inline event handlers from
|
|
||||||
// being executed immediately
|
|
||||||
context = context || ( support.createHTMLDocument ?
|
|
||||||
document.implementation.createHTMLDocument( "" ) :
|
|
||||||
document );
|
|
||||||
|
|
||||||
var parsed = rsingleTag.exec( data ),
|
var parsed = rsingleTag.exec( data ),
|
||||||
scripts = !keepScripts && [];
|
scripts = !keepScripts && [];
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
define( [
|
|
||||||
"../var/document",
|
|
||||||
"../var/support"
|
|
||||||
], function( document, support ) {
|
|
||||||
|
|
||||||
// Support: Safari 8+
|
|
||||||
// In Safari 8 documents created via document.implementation.createHTMLDocument
|
|
||||||
// collapse sibling forms: the second one becomes a child of the first one.
|
|
||||||
// Because of that, this security measure has to be disabled in Safari 8.
|
|
||||||
// https://bugs.webkit.org/show_bug.cgi?id=137337
|
|
||||||
support.createHTMLDocument = ( function() {
|
|
||||||
if ( !document.implementation.createHTMLDocument ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var doc = document.implementation.createHTMLDocument( "" );
|
|
||||||
doc.body.innerHTML = "<form></form><form></form>";
|
|
||||||
return doc.body.childNodes.length === 2;
|
|
||||||
} )();
|
|
||||||
|
|
||||||
return support;
|
|
||||||
} );
|
|
@ -1541,22 +1541,6 @@ QUnit.test("jQuery.parseHTML", function( assert ) {
|
|||||||
assert.equal( jQuery.parseHTML( "<td><td>" )[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
|
assert.equal( jQuery.parseHTML( "<td><td>" )[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( jQuery.support.createHTMLDocument && !/opera.*version\/12\.1/i.test( navigator.userAgent ) ) {
|
|
||||||
QUnit.asyncTest( "jQuery.parseHTML", function( assert ) {
|
|
||||||
assert.expect( 1 );
|
|
||||||
|
|
||||||
Globals.register( "parseHTMLError" );
|
|
||||||
|
|
||||||
jQuery.globalEval( "parseHTMLError = false;" );
|
|
||||||
jQuery.parseHTML( "<img src=x onerror='parseHTMLError = true'>" );
|
|
||||||
|
|
||||||
window.setTimeout( function() {
|
|
||||||
QUnit.start();
|
|
||||||
assert.equal( window.parseHTMLError, false, "onerror eventhandler has not been called." );
|
|
||||||
}, 2000 );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
QUnit.test( "jQuery.parseJSON", function( assert ) {
|
QUnit.test( "jQuery.parseJSON", function( assert ) {
|
||||||
assert.expect( 20 );
|
assert.expect( 20 );
|
||||||
|
|
||||||
|
@ -105,7 +105,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": version >= 13,
|
"clearCloneStyle": version >= 13,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -146,7 +145,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -187,7 +185,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": false,
|
"clearCloneStyle": false,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -228,7 +225,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": false,
|
"clearCloneStyle": false,
|
||||||
"cors": false,
|
"cors": false,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -269,7 +265,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": false,
|
"cors": false,
|
||||||
"createHTMLDocument": false,
|
|
||||||
"cssFloat": false,
|
"cssFloat": false,
|
||||||
"deleteExpando": false,
|
"deleteExpando": false,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -310,7 +305,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": false,
|
"cors": false,
|
||||||
"createHTMLDocument": false,
|
|
||||||
"cssFloat": false,
|
"cssFloat": false,
|
||||||
"deleteExpando": false,
|
"deleteExpando": false,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -351,7 +345,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": false,
|
"cors": false,
|
||||||
"createHTMLDocument": false,
|
|
||||||
"cssFloat": false,
|
"cssFloat": false,
|
||||||
"deleteExpando": false,
|
"deleteExpando": false,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -395,7 +388,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -436,7 +428,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -477,7 +468,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": false,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -518,7 +508,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": false,
|
"checkOn": false,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -559,7 +548,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -600,7 +588,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -641,7 +628,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -682,7 +668,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": false,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -723,7 +708,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -764,7 +748,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": true,
|
"checkOn": true,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -805,7 +788,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": false,
|
"checkOn": false,
|
||||||
"clearCloneStyle": true,
|
"clearCloneStyle": true,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
@ -846,7 +828,6 @@ testIframeWithCallback(
|
|||||||
"checkOn": false,
|
"checkOn": false,
|
||||||
"clearCloneStyle": false,
|
"clearCloneStyle": false,
|
||||||
"cors": true,
|
"cors": true,
|
||||||
"createHTMLDocument": true,
|
|
||||||
"cssFloat": true,
|
"cssFloat": true,
|
||||||
"deleteExpando": true,
|
"deleteExpando": true,
|
||||||
"enctype": true,
|
"enctype": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user