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
61bb6127
Commit
61bb6127
authored
Jan 07, 2015
by
Timo Tijhof
Committed by
Timmy Willison
Jan 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core: Return empty array instead of null for parseHTML("")
Fixes gh-1997 Close gh-1998 Conflicts: test/unit/core.js
parent
30ace26c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
parseHTML.js
src/core/parseHTML.js
+2
-2
core.js
test/unit/core.js
+9
-4
No files found.
src/core/parseHTML.js
View file @
61bb6127
...
@@ -14,8 +14,8 @@ define([
...
@@ -14,8 +14,8 @@ define([
// defaults to document
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
// keepScripts (optional): If true, will include scripts passed in the html string
jQuery
.
parseHTML
=
function
(
data
,
context
,
keepScripts
)
{
jQuery
.
parseHTML
=
function
(
data
,
context
,
keepScripts
)
{
if
(
!
data
||
typeof
data
!==
"string"
)
{
if
(
typeof
data
!==
"string"
)
{
return
null
;
return
[]
;
}
}
if
(
typeof
context
===
"boolean"
)
{
if
(
typeof
context
===
"boolean"
)
{
keepScripts
=
context
;
keepScripts
=
context
;
...
...
test/unit/core.js
View file @
61bb6127
...
@@ -1285,13 +1285,18 @@ test("jQuery.proxy", function(){
...
@@ -1285,13 +1285,18 @@ test("jQuery.proxy", function(){
});
});
test
(
"jQuery.parseHTML"
,
function
()
{
test
(
"jQuery.parseHTML"
,
function
()
{
expect
(
17
);
expect
(
22
);
var
html
,
nodes
;
var
html
,
nodes
;
equal
(
jQuery
.
parseHTML
(),
null
,
"Nothing in, null out."
);
deepEqual
(
jQuery
.
parseHTML
(),
[],
"Without arguments"
);
equal
(
jQuery
.
parseHTML
(
null
),
null
,
"Null in, null out."
);
deepEqual
(
jQuery
.
parseHTML
(
undefined
),
[],
"Undefined"
);
equal
(
jQuery
.
parseHTML
(
""
),
null
,
"Empty string in, null out."
);
deepEqual
(
jQuery
.
parseHTML
(
null
),
[],
"Null"
);
deepEqual
(
jQuery
.
parseHTML
(
false
),
[],
"Boolean false"
);
deepEqual
(
jQuery
.
parseHTML
(
0
),
[],
"Zero"
);
deepEqual
(
jQuery
.
parseHTML
(
true
),
[],
"Boolean true"
);
deepEqual
(
jQuery
.
parseHTML
(
42
),
[],
"Positive number"
);
deepEqual
(
jQuery
.
parseHTML
(
""
),
[],
"Empty string"
);
throws
(
function
()
{
throws
(
function
()
{
jQuery
.
parseHTML
(
"<div></div>"
,
document
.
getElementById
(
"form"
)
);
jQuery
.
parseHTML
(
"<div></div>"
,
document
.
getElementById
(
"form"
)
);
},
"Passing an element as the context raises an exception (context should be a document)"
);
},
"Passing an element as the context raises an exception (context should be a document)"
);
...
...
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