Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
828a718a
Commit
828a718a
authored
Dec 10, 2014
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core: introduce createHTMLDocument in parseHTML; Safari 8/IE8 left out
Close gh-1506
parent
51564bbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
4 deletions
+83
-4
parseHTML.js
src/core/parseHTML.js
+12
-3
support.js
src/core/support.js
+15
-0
core.js
test/unit/core.js
+16
-0
support.js
test/unit/support.js
+40
-1
No files found.
src/core/parseHTML.js
View file @
828a718a
define
([
define
([
"../core"
,
"../core"
,
"./var/rsingleTag"
,
"./var/rsingleTag"
,
"../manipulation"
// buildFragment
],
function
(
jQuery
,
rsingleTag
)
{
// This is the only module that needs core/support
"./support"
,
// buildFragment
"../manipulation"
],
function
(
jQuery
,
rsingleTag
,
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,
...
@@ -16,7 +21,11 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
...
@@ -16,7 +21,11 @@ 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
&&
[];
...
...
src/core/support.js
0 → 100644
View file @
828a718a
define
([
"../var/support"
],
function
(
support
)
{
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
;
});
test/unit/core.js
View file @
828a718a
...
@@ -1348,6 +1348,22 @@ test("jQuery.parseHTML", function() {
...
@@ -1348,6 +1348,22 @@ test("jQuery.parseHTML", function() {
equal
(
jQuery
.
parseHTML
(
"<td><td>"
)[
1
].
parentNode
.
nodeType
,
11
,
"parentNode should be documentFragment"
);
equal
(
jQuery
.
parseHTML
(
"<td><td>"
)[
1
].
parentNode
.
nodeType
,
11
,
"parentNode should be documentFragment"
);
});
});
if
(
jQuery
.
support
.
createHTMLDocument
)
{
asyncTest
(
"jQuery.parseHTML"
,
function
()
{
expect
(
1
);
Globals
.
register
(
"parseHTMLError"
);
jQuery
.
globalEval
(
"parseHTMLError = false;"
);
jQuery
.
parseHTML
(
"<img src=x onerror='parseHTMLError = true'>"
);
window
.
setTimeout
(
function
()
{
start
();
equal
(
window
.
parseHTMLError
,
false
,
"onerror eventhandler has not been called."
);
},
2000
);
});
}
test
(
"jQuery.parseJSON"
,
function
()
{
test
(
"jQuery.parseJSON"
,
function
()
{
expect
(
20
);
expect
(
20
);
...
...
test/unit/support.js
View file @
828a718a
...
@@ -79,6 +79,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -79,6 +79,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
@@ -108,6 +109,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -108,6 +109,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
false
,
"clearCloneStyle"
:
false
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
true
,
"focusinBubbles"
:
true
,
...
@@ -137,6 +139,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -137,6 +139,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
false
,
"clearCloneStyle"
:
false
,
"cors"
:
false
,
"cors"
:
false
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
true
,
"focusinBubbles"
:
true
,
...
@@ -166,6 +169,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -166,6 +169,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
false
,
"cors"
:
false
,
"createHTMLDocument"
:
false
,
"cssFloat"
:
false
,
"cssFloat"
:
false
,
"deleteExpando"
:
false
,
"deleteExpando"
:
false
,
"focusinBubbles"
:
true
,
"focusinBubbles"
:
true
,
...
@@ -186,7 +190,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -186,7 +190,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"style"
:
false
,
"style"
:
false
,
"submitBubbles"
:
false
"submitBubbles"
:
false
};
};
}
else
if
(
/
(
6|7
|8
)\.
0
(\.\d
+|
)
safari/i
.
test
(
userAgent
)
)
{
}
else
if
(
/
(
6|7
)\.
0
(\.\d
+|
)
safari/i
.
test
(
userAgent
)
)
{
expected
=
{
expected
=
{
"ajax"
:
true
,
"ajax"
:
true
,
"boxSizingReliable"
:
true
,
"boxSizingReliable"
:
true
,
...
@@ -195,6 +199,37 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -195,6 +199,37 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"html5Clone"
:
true
,
"htmlSerialize"
:
true
,
"input"
:
true
,
"leadingWhitespace"
:
true
,
"noCloneChecked"
:
true
,
"noCloneEvent"
:
true
,
"opacity"
:
true
,
"optDisabled"
:
true
,
"optSelected"
:
true
,
"ownLast"
:
false
,
"pixelPosition"
:
false
,
"radioValue"
:
true
,
"reliableHiddenOffsets"
:
true
,
"reliableMarginRight"
:
true
,
"style"
:
true
,
"submitBubbles"
:
true
};
}
else
if
(
/8.0
(\.\d
+|
)
safari/i
.
test
(
userAgent
)
)
{
expected
=
{
"ajax"
:
true
,
"boxSizingReliable"
:
true
,
"changeBubbles"
:
true
,
"checkClone"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
false
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
@@ -224,6 +259,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -224,6 +259,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
@@ -253,6 +289,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -253,6 +289,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
true
,
"checkOn"
:
true
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
@@ -282,6 +319,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -282,6 +319,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
false
,
"checkOn"
:
false
,
"clearCloneStyle"
:
true
,
"clearCloneStyle"
:
true
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
@@ -311,6 +349,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
...
@@ -311,6 +349,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"checkOn"
:
false
,
"checkOn"
:
false
,
"clearCloneStyle"
:
false
,
"clearCloneStyle"
:
false
,
"cors"
:
true
,
"cors"
:
true
,
"createHTMLDocument"
:
true
,
"cssFloat"
:
true
,
"cssFloat"
:
true
,
"deleteExpando"
:
true
,
"deleteExpando"
:
true
,
"focusinBubbles"
:
false
,
"focusinBubbles"
:
false
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment