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
b2d15586
Commit
b2d15586
authored
Jul 06, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a bunch of improved support for DOM Element arrays - along with a new $.A( ... ) function.
parent
9b6df19c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
23 deletions
+49
-23
jquery.js
jquery/jquery.js
+49
-23
No files found.
jquery/jquery.js
View file @
b2d15586
...
@@ -12,50 +12,60 @@
...
@@ -12,50 +12,60 @@
// Global undefined variable
// Global undefined variable
window
.
undefined
=
window
.
undefined
;
window
.
undefined
=
window
.
undefined
;
// Map over the $ in case of overwrite
if
(
$
)
var
_$
=
$
;
/**
/**
* Create a new jQuery Object
* Create a new jQuery Object
* @constructor
* @constructor
*/
*/
var
$
=
jQuery
=
function
(
a
,
c
)
{
function
jQuery
(
a
,
c
)
{
/*
/*
* Handle support for overriding other $() functions. Way too many libraries
* Handle support for overriding other $() functions. Way too many libraries
* provide this function to simply ignore it and overwrite it.
* provide this function to simply ignore it and overwrite it.
*/
*/
// Check to see if this is a possible collision case
// Check to see if this is a possible collision case
if
(
_$
&&
!
c
&&
(
a
.
constructor
==
String
&&
if
(
jQuery
.
_$
&&
!
c
&&
a
.
constructor
==
String
&&
// Make sure that the expression is a colliding one
// Make sure that the expression is a colliding one
!
/
[^
a-zA-Z0-9_-
]
/
.
test
(
a
)
&&
!
/
[^
a-zA-Z0-9_-
]
/
.
test
(
a
)
&&
// and that there are no elements that match it
// and that there are no elements that match it
// (this is the one truly ambiguous case)
// (this is the one truly ambiguous case)
!
document
.
getElementsByTagName
(
a
).
length
)
||
!
document
.
getElementsByTagName
(
a
).
length
)
// Watch for an array being passed in (Prototype 1.5)
a
.
constructor
==
Array
)
// Use the default method, in case it works some voodoo
// Use the default method, in case it works some voodoo
return
_$
(
a
);
return
jQuery
.
_$
(
a
);
// Watch for when a jQuery object is passed in as an arg
// Make sure t hat a selection was provided
if
(
a
&&
a
.
jquery
)
a
=
a
||
jQuery
.
context
||
document
;
// Watch for when a jQuery object is passed as the selector
if
(
a
.
jquery
)
return
a
;
return
a
;
// Watch for when a jQuery object is passed at the context
if
(
c
&&
c
.
jquery
)
return
$
(
c
.
get
()).
find
(
a
);
// If the context is global, return a new object
// If the context is global, return a new object
if
(
window
==
this
)
if
(
window
==
this
)
return
new
jQuery
(
a
,
c
);
return
new
jQuery
(
a
,
c
);
// Find the matching elements and save them for later
// Watch for when an array is passed in
this
.
cur
=
jQuery
.
Select
(
if
(
a
.
constructor
==
Array
)
a
||
jQuery
.
context
||
document
,
// Assume that it's an array of DOM Elements
c
&&
c
.
jquery
&&
c
.
get
(
0
)
||
c
this
.
cur
=
a
;
);
else
// Find the matching elements and save them for later
this
.
cur
=
jQuery
.
Select
(
a
,
c
);
}
}
// Map over the $ in case of overwrite
if
(
$
)
jQuery
.
_$
=
$
;
// Map the jQuery namespace to the '$' one
var
$
=
jQuery
;
jQuery
.
fn
=
jQuery
.
prototype
=
{
jQuery
.
fn
=
jQuery
.
prototype
=
{
/**
/**
* The current SVN version of jQuery.
* The current SVN version of jQuery.
...
@@ -353,6 +363,22 @@ jQuery.fn = jQuery.prototype = {
...
@@ -353,6 +363,22 @@ jQuery.fn = jQuery.prototype = {
}
}
};
};
/**
* Similar to the Prototype $A() function, only it allows you to
* forcefully pass array-like structures into $().
*/
jQuery
.
A
=
function
(
a
){
// Create a temporary, clean, array
var
r
=
[];
// and copy the old array contents over to it
for
(
var
i
=
0
;
i
<
a
.
length
;
i
++
)
r
.
push
(
a
[
i
]
);
// Return the sane jQuery object
return
$
(
r
);
};
jQuery
.
className
=
{
jQuery
.
className
=
{
add
:
function
(
o
,
c
){
add
:
function
(
o
,
c
){
if
(
jQuery
.
hasWord
(
o
,
c
))
return
;
if
(
jQuery
.
hasWord
(
o
,
c
))
return
;
...
@@ -525,8 +551,8 @@ jQuery.token = [
...
@@ -525,8 +551,8 @@ jQuery.token = [
jQuery
.
Select
=
function
(
t
,
context
)
{
jQuery
.
Select
=
function
(
t
,
context
)
{
context
=
context
||
jQuery
.
context
||
document
;
context
=
context
||
jQuery
.
context
||
document
;
if
(
t
.
constructor
!=
String
)
return
t
.
constructor
==
Array
?
t
:
[
t
];
if
(
t
.
constructor
!=
String
)
return
[
t
];
if
(
!
t
.
indexOf
(
"//"
)
)
{
if
(
!
t
.
indexOf
(
"//"
)
)
{
context
=
context
.
documentElement
;
context
=
context
.
documentElement
;
...
...
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