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
18a6fbbb
Commit
18a6fbbb
authored
Jul 27, 2009
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an improvement to quickExpr and some more tests for jQuery('html'). Fixes #4979.
parent
8c18dcde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
core.js
src/core.js
+3
-3
core.js
test/unit/core.js
+9
-1
No files found.
src/core.js
View file @
18a6fbbb
...
@@ -20,7 +20,7 @@ var jQuery = function( selector, context ) {
...
@@ -20,7 +20,7 @@ var jQuery = function( selector, context ) {
// A simple way to check for HTML strings or ID strings
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
// (both of which we optimize for)
quickExpr
=
/^
[^
<
]
*
(
<
(
.|
\s)
+>
)[^
>
]
*$|^#
([\w
-
]
+
)
$/
,
quickExpr
=
/^
[^
<
]
*
(
<
[\w\W]
+>
)[^
>
]
*$|^#
([\w
-
]
+
)
$/
,
// Is it a simple selector
// Is it a simple selector
isSimple
=
/^.
[^
:#
\[\.
,
]
*$/
,
isSimple
=
/^.
[^
:#
\[\.
,
]
*$/
,
...
@@ -70,12 +70,12 @@ jQuery.fn = jQuery.prototype = {
...
@@ -70,12 +70,12 @@ jQuery.fn = jQuery.prototype = {
// HANDLE: $("#id")
// HANDLE: $("#id")
}
else
{
}
else
{
elem
=
document
.
getElementById
(
match
[
3
]
);
elem
=
document
.
getElementById
(
match
[
2
]
);
if
(
elem
)
{
if
(
elem
)
{
// Handle the case where IE and Opera return items
// Handle the case where IE and Opera return items
// by name instead of ID
// by name instead of ID
if
(
elem
.
id
!==
match
[
3
]
)
return
rootjQuery
.
find
(
selector
);
if
(
elem
.
id
!==
match
[
2
]
)
return
rootjQuery
.
find
(
selector
);
// Otherwise, we inject the element directly into the jQuery object
// Otherwise, we inject the element directly into the jQuery object
this
.
length
++
;
this
.
length
++
;
...
...
test/unit/core.js
View file @
18a6fbbb
...
@@ -303,7 +303,7 @@ test("isXMLDoc - XML", function() {
...
@@ -303,7 +303,7 @@ test("isXMLDoc - XML", function() {
}
}
test
(
"jQuery('html')"
,
function
()
{
test
(
"jQuery('html')"
,
function
()
{
expect
(
8
);
expect
(
13
);
reset
();
reset
();
jQuery
.
foo
=
false
;
jQuery
.
foo
=
false
;
...
@@ -313,6 +313,14 @@ test("jQuery('html')", function() {
...
@@ -313,6 +313,14 @@ test("jQuery('html')", function() {
jQuery
(
"body"
).
append
(
"<script>jQuery.foo='test';</script>"
);
jQuery
(
"body"
).
append
(
"<script>jQuery.foo='test';</script>"
);
ok
(
jQuery
.
foo
,
"Executing a scripts contents in the right context"
);
ok
(
jQuery
.
foo
,
"Executing a scripts contents in the right context"
);
// Test multi-line HTML
var
div
=
jQuery
(
"<div>
\
r
\n
some text
\n
<p>some p</p>
\n
more text
\
r
\n
</div>"
)[
0
];
equals
(
div
.
nodeName
.
toUpperCase
(),
"DIV"
,
"Make sure we're getting a div."
);
equals
(
div
.
firstChild
.
nodeType
,
3
,
"Text node."
);
equals
(
div
.
lastChild
.
nodeType
,
3
,
"Text node."
);
equals
(
div
.
childNodes
[
1
].
nodeType
,
1
,
"Paragraph."
);
equals
(
div
.
childNodes
[
1
].
firstChild
.
nodeType
,
3
,
"Paragraph text."
);
reset
();
reset
();
ok
(
jQuery
(
"<link rel='stylesheet'/>"
)[
0
],
"Creating a link"
);
ok
(
jQuery
(
"<link rel='stylesheet'/>"
)[
0
],
"Creating a link"
);
...
...
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