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
67c640bb
Commit
67c640bb
authored
May 01, 2007
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving constructor code to jQuery.prototype.init for more flexibility
parent
13d2ef92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
30 deletions
+47
-30
jquery.js
src/jquery/jquery.js
+47
-30
No files found.
src/jquery/jquery.js
View file @
67c640bb
...
@@ -26,37 +26,8 @@ var jQuery = function(a,c) {
...
@@ -26,37 +26,8 @@ var jQuery = function(a,c) {
// 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
);
// Make sure that a selection was provided
a
=
a
||
document
;
// HANDLE: $(function)
// Shortcut for document ready
if
(
jQuery
.
isFunction
(
a
)
)
return
new
jQuery
(
document
)[
jQuery
.
fn
.
ready
?
"ready"
:
"load"
](
a
);
// Handle HTML strings
if
(
typeof
a
==
"string"
)
{
// HANDLE: $(html) -> $(array)
var
m
=
/^
[^
<
]
*
(
<
(
.|
\s)
+>
)[^
>
]
*$/
.
exec
(
a
);
if
(
m
)
a
=
jQuery
.
clean
(
[
m
[
1
]
]
);
// HANDLE: $(expr)
else
return
new
jQuery
(
c
).
find
(
a
);
}
return
this
.
setArray
(
return
this
.
init
(
a
,
c
);
// HANDLE: $(array)
a
.
constructor
==
Array
&&
a
||
// HANDLE: $(arraylike)
// Watch for when an array-like object is passed as the selector
(
a
.
jquery
||
a
.
length
&&
a
!=
window
&&
!
a
.
nodeType
&&
a
[
0
]
!=
undefined
&&
a
[
0
].
nodeType
)
&&
jQuery
.
makeArray
(
a
)
||
// HANDLE: $(*)
[
a
]
);
};
};
// Map over the $ in case of overwrite
// Map over the $ in case of overwrite
...
@@ -169,6 +140,52 @@ var $ = jQuery;
...
@@ -169,6 +140,52 @@ var $ = jQuery;
*/
*/
jQuery
.
fn
=
jQuery
.
prototype
=
{
jQuery
.
fn
=
jQuery
.
prototype
=
{
/**
* Initialize a new jQuery object
*
* @private
* @name init
* @param String|Function|Element|Array<Element>|jQuery a selector
* @param jQuery|Element|Array<Element> c context
* @cat Core
*/
init
:
function
(
a
,
c
)
{
// Make sure that a selection was provided
a
=
a
||
document
;
// HANDLE: $(function)
// Shortcut for document ready
if
(
jQuery
.
isFunction
(
a
)
)
return
new
jQuery
(
document
)[
jQuery
.
fn
.
ready
?
"ready"
:
"load"
](
a
);
// Handle HTML strings
if
(
typeof
a
==
"string"
)
{
// HANDLE: $(html) -> $(array)
var
m
=
/^
[^
<
]
*
(
<
(
.|
\s)
+>
)[^
>
]
*$/
.
exec
(
a
);
if
(
m
)
a
=
jQuery
.
clean
(
[
m
[
1
]
]
);
// HANDLE: $(expr)
else
{
var
r
=
new
jQuery
(
c
).
find
(
a
);
r
.
selector
=
a
;
r
.
context
=
c
;
return
r
;
}
}
return
this
.
setArray
(
// HANDLE: $(array)
a
.
constructor
==
Array
&&
a
||
// HANDLE: $(arraylike)
// Watch for when an array-like object is passed as the selector
(
a
.
jquery
||
a
.
length
&&
a
!=
window
&&
!
a
.
nodeType
&&
a
[
0
]
!=
undefined
&&
a
[
0
].
nodeType
)
&&
jQuery
.
makeArray
(
a
)
||
// HANDLE: $(*)
[
a
]
);
},
/**
/**
* The current version of jQuery.
* The current version of jQuery.
*
*
...
...
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