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
3a80de1c
Commit
3a80de1c
authored
May 03, 2009
by
Ariel Flesler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jquery core: $() -> $(document) and $(undefined) -> $([]). Removed a duplicated block.
parent
e45b4160
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
core.js
src/core.js
+1
-7
core.js
test/unit/core.js
+13
-7
No files found.
src/core.js
View file @
3a80de1c
...
...
@@ -18,7 +18,7 @@ var window = this,
jQuery
=
window
.
jQuery
=
window
.
$
=
function
(
selector
,
context
)
{
// The jQuery object is actually just the init constructor 'enhanced'
return
selector
===
undefined
?
return
arguments
.
length
===
0
?
rootjQuery
:
new
jQuery
.
fn
.
init
(
selector
,
context
);
},
...
...
@@ -36,12 +36,6 @@ var window = this,
// Save a reference to the core toString method
toString
=
Object
.
prototype
.
toString
;
// Define the main jQuery method
jQuery
=
window
.
jQuery
=
window
.
$
=
function
(
selector
,
context
)
{
// The jQuery object is actually just the init constructor 'enhanced'
return
new
jQuery
.
fn
.
init
(
selector
,
context
);
};
jQuery
.
fn
=
jQuery
.
prototype
=
{
init
:
function
(
selector
,
context
)
{
var
match
,
elem
,
ret
;
...
...
test/unit/core.js
View file @
3a80de1c
...
...
@@ -12,8 +12,19 @@ test("Basic requirements", function() {
});
test
(
"jQuery()"
,
function
()
{
expect
(
8
);
expect
(
11
);
// Basic constructor's behavior
equals
(
jQuery
().
length
,
1
,
"jQuery() === jQuery(document)"
);
equals
(
jQuery
(
undefined
).
length
,
0
,
"jQuery(undefined) === jQuery([])"
);
equals
(
jQuery
(
null
).
length
,
0
,
"jQuery(null) === jQuery([])"
);
equals
(
jQuery
(
""
).
length
,
0
,
"jQuery('') === jQuery([])"
);
// 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)"
);
var
main
=
jQuery
(
"#main"
);
isSet
(
jQuery
(
"div p"
,
main
).
get
(),
q
(
"sndp"
,
"en"
,
"sap"
),
"Basic selector with jQuery object as context"
);
...
...
@@ -42,11 +53,6 @@ test("jQuery()", function() {
var
div
=
jQuery
(
"<div/><hr/><code/><b/>"
);
equals
(
div
.
length
,
4
,
"Correct number of elements generated for div hr code b"
);
// can actually yield more than one, when iframes are included, the window is an array as well
equals
(
jQuery
(
window
).
length
,
1
,
"Correct number of elements generated for window"
);
equals
(
jQuery
(
document
).
length
,
1
,
"Correct number of elements generated for document"
);
equals
(
jQuery
([
1
,
2
,
3
]).
get
(
1
),
2
,
"Test passing an array to the factory"
);
equals
(
jQuery
(
document
.
body
).
get
(
0
),
jQuery
(
'body'
).
get
(
0
),
"Test passing an html node to the factory"
);
...
...
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