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
e0856738
Commit
e0856738
authored
Jan 19, 2011
by
carpie
Committed by
Dave Methvin
Apr 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip id regex check when large html strings are passed to the jQuery constructor (#7990).
parent
ceaf0939
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
core.js
src/core.js
+6
-1
core.js
test/unit/core.js
+14
-1
No files found.
src/core.js
View file @
e0856738
...
@@ -96,7 +96,12 @@ jQuery.fn = jQuery.prototype = {
...
@@ -96,7 +96,12 @@ jQuery.fn = jQuery.prototype = {
// Handle HTML strings
// Handle HTML strings
if
(
typeof
selector
===
"string"
)
{
if
(
typeof
selector
===
"string"
)
{
// Are we dealing with HTML string or an ID?
// Are we dealing with HTML string or an ID?
match
=
quickExpr
.
exec
(
selector
);
if
(
selector
.
length
>
1024
)
{
// Assume very large strings are HTML and skip the regex check
match
=
[
null
,
selector
,
null
];
}
else
{
match
=
quickExpr
.
exec
(
selector
);
}
// Verify a match, and that no context was specified for #id
// Verify a match, and that no context was specified for #id
if
(
match
&&
(
match
[
1
]
||
!
context
)
)
{
if
(
match
&&
(
match
[
1
]
||
!
context
)
)
{
...
...
test/unit/core.js
View file @
e0856738
...
@@ -469,7 +469,7 @@ test("isWindow", function() {
...
@@ -469,7 +469,7 @@ test("isWindow", function() {
});
});
test
(
"jQuery('html')"
,
function
()
{
test
(
"jQuery('html')"
,
function
()
{
expect
(
1
5
);
expect
(
1
8
);
QUnit
.
reset
();
QUnit
.
reset
();
jQuery
.
foo
=
false
;
jQuery
.
foo
=
false
;
...
@@ -501,6 +501,19 @@ test("jQuery('html')", function() {
...
@@ -501,6 +501,19 @@ test("jQuery('html')", function() {
ok
(
jQuery
(
"<div></div>"
)[
0
],
"Create a div with closing tag."
);
ok
(
jQuery
(
"<div></div>"
)[
0
],
"Create a div with closing tag."
);
ok
(
jQuery
(
"<table></table>"
)[
0
],
"Create a table with closing tag."
);
ok
(
jQuery
(
"<table></table>"
)[
0
],
"Create a table with closing tag."
);
// Test very large html string #7990
var
i
;
var
li
=
'<li>very large html string</li>'
;
var
html
=
[
'<ul>'
];
for
(
i
=
0
;
i
<
50000
;
i
+=
1
)
{
html
.
push
(
li
);
}
html
.
push
(
'</ul>'
);
html
=
jQuery
(
html
.
join
(
''
))[
0
];
equals
(
html
.
nodeName
.
toUpperCase
(),
'UL'
);
equals
(
html
.
firstChild
.
nodeName
.
toUpperCase
(),
'LI'
);
equals
(
html
.
childNodes
.
length
,
50000
);
});
});
test
(
"jQuery('html', context)"
,
function
()
{
test
(
"jQuery('html', context)"
,
function
()
{
...
...
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