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
b8076a91
Commit
b8076a91
authored
Jan 28, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Landing some minor perf optimization to jQuery().
parent
0db207da
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
core.js
src/core.js
+12
-4
core.js
test/unit/core.js
+1
-1
No files found.
src/core.js
View file @
b8076a91
...
@@ -70,6 +70,14 @@ jQuery.fn = jQuery.prototype = {
...
@@ -70,6 +70,14 @@ jQuery.fn = jQuery.prototype = {
return
this
;
return
this
;
}
}
// The body element only exists once, optimize finding it
if
(
selector
===
"body"
&&
!
context
)
{
this
.
context
=
this
[
0
]
=
document
.
body
;
this
.
selector
=
"body"
;
this
.
length
=
1
;
return
this
;
}
// 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?
...
@@ -128,6 +136,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -128,6 +136,7 @@ jQuery.fn = jQuery.prototype = {
this
.
selector
=
selector
;
this
.
selector
=
selector
;
this
.
context
=
document
;
this
.
context
=
document
;
selector
=
document
.
getElementsByTagName
(
selector
);
selector
=
document
.
getElementsByTagName
(
selector
);
return
jQuery
.
merge
(
this
,
selector
);
// HANDLE: $(expr, $(...))
// HANDLE: $(expr, $(...))
}
else
if
(
!
context
||
context
.
jquery
)
{
}
else
if
(
!
context
||
context
.
jquery
)
{
...
@@ -150,9 +159,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -150,9 +159,7 @@ jQuery.fn = jQuery.prototype = {
this
.
context
=
selector
.
context
;
this
.
context
=
selector
.
context
;
}
}
return
jQuery
.
isArray
(
selector
)
?
return
jQuery
.
makeArray
(
selector
,
this
);
this
.
setArray
(
selector
)
:
jQuery
.
makeArray
(
selector
,
this
);
},
},
// Start with an empty selector
// Start with an empty selector
...
@@ -604,6 +611,7 @@ jQuery.extend({
...
@@ -604,6 +611,7 @@ jQuery.extend({
for
(
var
l
=
second
.
length
;
j
<
l
;
j
++
)
{
for
(
var
l
=
second
.
length
;
j
<
l
;
j
++
)
{
first
[
i
++
]
=
second
[
j
];
first
[
i
++
]
=
second
[
j
];
}
}
}
else
{
}
else
{
while
(
second
[
j
]
!==
undefined
)
{
while
(
second
[
j
]
!==
undefined
)
{
first
[
i
++
]
=
second
[
j
++
];
first
[
i
++
]
=
second
[
j
++
];
...
...
test/unit/core.js
View file @
b8076a91
...
@@ -25,7 +25,7 @@ test("jQuery()", function() {
...
@@ -25,7 +25,7 @@ test("jQuery()", function() {
equals
(
jQuery
(
obj
).
selector
,
"div"
,
"jQuery(jQueryObj) == jQueryObj"
);
equals
(
jQuery
(
obj
).
selector
,
"div"
,
"jQuery(jQueryObj) == jQueryObj"
);
// can actually yield more than one, when iframes are included, the window is an array as well
// can actually yield more than one, when iframes are included, the window is an array as well
equals
(
1
,
jQuery
(
window
).
length
,
"Correct number of elements generated for jQuery(window)"
);
equals
(
jQuery
(
window
).
length
,
1
,
"Correct number of elements generated for jQuery(window)"
);
var
main
=
jQuery
(
"#main"
);
var
main
=
jQuery
(
"#main"
);
...
...
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