Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac1e6ea

Browse files
timmywilmarkelog
authored andcommitted
Core: re-introduce createHTMLDocument in parseHTML; Safari 8 left out
Closegh-1505
1 parentf64523e commitac1e6ea

File tree

5 files changed

+67
-6
lines changed

5 files changed

+67
-6
lines changed

‎src/core/parseHTML.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ define([
22
"../core",
33
"./var/rsingleTag",
44

5-
"../manipulation"// buildFragment
6-
],function(jQuery,rsingleTag){
5+
// This is the only module that needs core/support
6+
"./support",
7+
8+
// buildFragment
9+
"../manipulation"
10+
],function(jQuery,rsingleTag,support){
711

812
// data: string of html
913
// context (optional): If specified, the fragment will be created in this context,
@@ -17,7 +21,11 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
1721
keepScripts=context;
1822
context=false;
1923
}
20-
context=context||document;
24+
// document.implementation stops scripts or inline event handlers from
25+
// being executed immediately
26+
context=context||(support.createHTMLDocument ?
27+
document.implementation.createHTMLDocument("") :
28+
document);
2129

2230
varparsed=rsingleTag.exec(data),
2331
scripts=!keepScripts&&[];

‎src/core/support.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
define([
2+
"../var/support"
3+
],function(support){
4+
5+
support.createHTMLDocument=(function(){
6+
vardoc=document.implementation.createHTMLDocument("");
7+
doc.body.innerHTML="<form></form><form></form>";
8+
returndoc.body.childNodes.length===2;
9+
})();
10+
11+
returnsupport;
12+
});

‎test/data/testinit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ this.loadTests = function() {
301301
/**
302302
* Run in noConflict mode
303303
*/
304-
if(jQuery.noConflict){
304+
if(jQuery.noConflict){
305305
jQuery.noConflict();
306306
}
307307

‎test/unit/core.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ test( "globalEval execution after script injection (#7862)", 1, function() {
235235
});
236236

237237
// This is not run in AMD mode
238-
if(jQuery.noConflict){
238+
if(jQuery.noConflict){
239239
test("noConflict",function(){
240240
expect(7);
241241

@@ -1370,6 +1370,22 @@ test("jQuery.parseHTML", function() {
13701370
ok(jQuery.parseHTML("<#if><tr><p>This is a test.</p></tr><#/if>")||true,"Garbage input should not cause error");
13711371
});
13721372

1373+
if(jQuery.support.createHTMLDocument){
1374+
asyncTest("jQuery.parseHTML",function(){
1375+
expect(1);
1376+
1377+
Globals.register("parseHTMLError");
1378+
1379+
jQuery.globalEval("parseHTMLError = false;");
1380+
jQuery.parseHTML("<img src=x onerror='parseHTMLError = true'>");
1381+
1382+
window.setTimeout(function(){
1383+
start();
1384+
equal(window.parseHTMLError,false,"onerror eventhandler has not been called.");
1385+
},2000);
1386+
});
1387+
}
1388+
13731389
test("jQuery.parseJSON",function(){
13741390
expect(20);
13751391

‎test/unit/support.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
6161
"checkOn":true,
6262
"clearCloneStyle":true,
6363
"cors":true,
64+
"createHTMLDocument":true,
6465
"focusinBubbles":false,
6566
"noCloneChecked":true,
6667
"optDisabled":true,
@@ -77,6 +78,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
7778
"checkOn":true,
7879
"clearCloneStyle":false,
7980
"cors":true,
81+
"createHTMLDocument":true,
8082
"focusinBubbles":true,
8183
"noCloneChecked":false,
8284
"optDisabled":true,
@@ -93,6 +95,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
9395
"checkOn":true,
9496
"clearCloneStyle":false,
9597
"cors":false,
98+
"createHTMLDocument":true,
9699
"focusinBubbles":true,
97100
"noCloneChecked":false,
98101
"optDisabled":true,
@@ -101,14 +104,32 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
101104
"radioValue":false,
102105
"reliableMarginRight":true
103106
};
104-
}elseif(/(6|7|8)\.0(\.\d+|)safari/i.test(userAgent)){
107+
}elseif(/(6|7)\.0(\.\d+|)safari/i.test(userAgent)){
105108
expected={
106109
"ajax":true,
107110
"boxSizingReliable":true,
108111
"checkClone":true,
109112
"checkOn":true,
110113
"clearCloneStyle":true,
111114
"cors":true,
115+
"createHTMLDocument":true,
116+
"focusinBubbles":false,
117+
"noCloneChecked":true,
118+
"optDisabled":true,
119+
"optSelected":true,
120+
"pixelPosition":false,
121+
"radioValue":true,
122+
"reliableMarginRight":true
123+
};
124+
}elseif(/8.0(\.\d+|)safari/i.test(userAgent)){
125+
expected={
126+
"ajax":true,
127+
"boxSizingReliable":true,
128+
"checkClone":true,
129+
"checkOn":true,
130+
"clearCloneStyle":true,
131+
"cors":true,
132+
"createHTMLDocument":false,
112133
"focusinBubbles":false,
113134
"noCloneChecked":true,
114135
"optDisabled":true,
@@ -125,6 +146,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
125146
"checkOn":true,
126147
"clearCloneStyle":true,
127148
"cors":true,
149+
"createHTMLDocument":true,
128150
"focusinBubbles":false,
129151
"noCloneChecked":true,
130152
"optDisabled":true,
@@ -141,6 +163,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
141163
"checkOn":true,
142164
"clearCloneStyle":true,
143165
"cors":true,
166+
"createHTMLDocument":true,
144167
"focusinBubbles":false,
145168
"noCloneChecked":true,
146169
"optDisabled":true,
@@ -157,6 +180,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
157180
"checkOn":false,
158181
"clearCloneStyle":true,
159182
"cors":true,
183+
"createHTMLDocument":true,
160184
"focusinBubbles":false,
161185
"noCloneChecked":true,
162186
"optDisabled":true,
@@ -173,6 +197,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
173197
"checkOn":false,
174198
"clearCloneStyle":false,
175199
"cors":true,
200+
"createHTMLDocument":true,
176201
"focusinBubbles":false,
177202
"noCloneChecked":true,
178203
"optDisabled":false,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp