Skip to content

Commit c5c3073

Browse files
committedMar 2, 2016
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. Refs cfe468f Refs gh-1505 Fixes gh-2941
1 parent 5d620be commit c5c3073

File tree

4 files changed

+3
-60
lines changed

4 files changed

+3
-60
lines changed
 

‎src/core/parseHTML.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ define( [
22
"../core",
33
"../var/document",
44
"./var/rsingleTag",
5-
"../manipulation/buildFragment",
6-
7-
// This is the only module that needs core/support
8-
"./support"
9-
], function( jQuery, document, rsingleTag, buildFragment, support ) {
5+
"../manipulation/buildFragment"
6+
], function( jQuery, document, rsingleTag, buildFragment ) {
107

118
// Argument "data" should be string of html
129
// context (optional): If specified, the fragment will be created in this context,
@@ -20,12 +17,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
2017
keepScripts = context;
2118
context = false;
2219
}
23-
24-
// Stop scripts or inline event handlers from being executed immediately
25-
// by using document.implementation
26-
context = context || ( support.createHTMLDocument ?
27-
document.implementation.createHTMLDocument( "" ) :
28-
document );
20+
context = context || document;
2921

3022
var parsed = rsingleTag.exec( data ),
3123
scripts = !keepScripts && [];

‎src/core/support.js

-18
This file was deleted.

‎test/unit/core.js

-16
Original file line numberDiff line numberDiff line change
@@ -1491,22 +1491,6 @@ QUnit.test("jQuery.parseHTML", function( assert ) {
14911491
assert.ok( jQuery.parseHTML("<#if><tr><p>This is a test.</p></tr><#/if>") || true, "Garbage input should not cause error" );
14921492
});
14931493

1494-
if ( jQuery.support.createHTMLDocument && !/opera.*version\/12\.1/i.test( navigator.userAgent ) ) {
1495-
QUnit.asyncTest( "jQuery.parseHTML", function( assert ) {
1496-
assert.expect( 1 );
1497-
1498-
Globals.register( "parseHTMLError" );
1499-
1500-
jQuery.globalEval( "parseHTMLError = false;" );
1501-
jQuery.parseHTML( "<img src=x onerror='parseHTMLError = true'>" );
1502-
1503-
window.setTimeout( function() {
1504-
QUnit.start();
1505-
assert.equal( window.parseHTMLError, false, "onerror eventhandler has not been called." );
1506-
}, 2000 );
1507-
} );
1508-
}
1509-
15101494
QUnit.test( "jQuery.parseJSON", function( assert ) {
15111495
assert.expect( 20 );
15121496

‎test/unit/support.js

-15
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ testIframeWithCallback(
6565
"checkOn": true,
6666
"clearCloneStyle": version >= 13,
6767
"cors": true,
68-
"createHTMLDocument": true,
6968
"focusin": false,
7069
"noCloneChecked": true,
7170
"optDisabled": true,
@@ -84,7 +83,6 @@ testIframeWithCallback(
8483
"checkOn": true,
8584
"clearCloneStyle": true,
8685
"cors": true,
87-
"createHTMLDocument": true,
8886
"focusin": false,
8987
"noCloneChecked": true,
9088
"optDisabled": true,
@@ -103,7 +101,6 @@ testIframeWithCallback(
103101
"checkOn": true,
104102
"clearCloneStyle": false,
105103
"cors": true,
106-
"createHTMLDocument": true,
107104
"focusin": true,
108105
"noCloneChecked": false,
109106
"optDisabled": true,
@@ -122,7 +119,6 @@ testIframeWithCallback(
122119
"checkOn": true,
123120
"clearCloneStyle": false,
124121
"cors": false,
125-
"createHTMLDocument": true,
126122
"focusin": true,
127123
"noCloneChecked": false,
128124
"optDisabled": true,
@@ -144,7 +140,6 @@ testIframeWithCallback(
144140
"checkOn": true,
145141
"clearCloneStyle": true,
146142
"cors": true,
147-
"createHTMLDocument": true,
148143
"focusin": false,
149144
"noCloneChecked": true,
150145
"optDisabled": true,
@@ -163,7 +158,6 @@ testIframeWithCallback(
163158
"checkOn": true,
164159
"clearCloneStyle": true,
165160
"cors": true,
166-
"createHTMLDocument": true,
167161
"focusin": false,
168162
"noCloneChecked": true,
169163
"optDisabled": true,
@@ -182,7 +176,6 @@ testIframeWithCallback(
182176
"checkOn": true,
183177
"clearCloneStyle": true,
184178
"cors": true,
185-
"createHTMLDocument": false,
186179
"focusin": false,
187180
"noCloneChecked": true,
188181
"optDisabled": true,
@@ -201,7 +194,6 @@ testIframeWithCallback(
201194
"checkOn": true,
202195
"clearCloneStyle": true,
203196
"cors": true,
204-
"createHTMLDocument": true,
205197
"focusin": false,
206198
"noCloneChecked": true,
207199
"optDisabled": true,
@@ -220,7 +212,6 @@ testIframeWithCallback(
220212
"checkOn": false,
221213
"clearCloneStyle": true,
222214
"cors": true,
223-
"createHTMLDocument": true,
224215
"focusin": false,
225216
"noCloneChecked": true,
226217
"optDisabled": true,
@@ -239,7 +230,6 @@ testIframeWithCallback(
239230
"checkOn": true,
240231
"clearCloneStyle": true,
241232
"cors": true,
242-
"createHTMLDocument": true,
243233
"focusin": false,
244234
"noCloneChecked": true,
245235
"optDisabled": true,
@@ -258,7 +248,6 @@ testIframeWithCallback(
258248
"checkOn": true,
259249
"clearCloneStyle": true,
260250
"cors": true,
261-
"createHTMLDocument": true,
262251
"focusin": false,
263252
"noCloneChecked": true,
264253
"optDisabled": true,
@@ -277,7 +266,6 @@ testIframeWithCallback(
277266
"checkOn": true,
278267
"clearCloneStyle": true,
279268
"cors": true,
280-
"createHTMLDocument": false,
281269
"focusin": false,
282270
"noCloneChecked": true,
283271
"optDisabled": true,
@@ -296,7 +284,6 @@ testIframeWithCallback(
296284
"checkOn": true,
297285
"clearCloneStyle": true,
298286
"cors": true,
299-
"createHTMLDocument": true,
300287
"focusin": false,
301288
"noCloneChecked": true,
302289
"optDisabled": true,
@@ -315,7 +302,6 @@ testIframeWithCallback(
315302
"checkOn": false,
316303
"clearCloneStyle": true,
317304
"cors": true,
318-
"createHTMLDocument": true,
319305
"focusin": false,
320306
"noCloneChecked": true,
321307
"optDisabled": true,
@@ -334,7 +320,6 @@ testIframeWithCallback(
334320
"checkOn": false,
335321
"clearCloneStyle": false,
336322
"cors": true,
337-
"createHTMLDocument": true,
338323
"focusin": false,
339324
"noCloneChecked": true,
340325
"optDisabled": false,

0 commit comments

Comments
 (0)