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
f2b0c77d
Commit
f2b0c77d
authored
Jan 20, 2011
by
jaubourg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jquery/jquery
parents
a7cb93be
0f6c7830
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
62 deletions
+16
-62
core.js
src/core.js
+16
-62
No files found.
src/core.js
View file @
f2b0c77d
...
@@ -15,9 +15,8 @@ var jQuery = function( selector, context ) {
...
@@ -15,9 +15,8 @@ var jQuery = function( selector, context ) {
// A central reference to the root jQuery(document)
// A central reference to the root jQuery(document)
rootjQuery
,
rootjQuery
,
// A simple way to check for HTML strings or ID strings
// A simple way to check for HTML strings
// (both of which we optimize for)
quickExpr
=
/^
[^
<
]
*
(
<
[\w\W]
+>
)[^
>
]
*$/
,
quickExpr
=
/^
(?:[^
<
]
*
(
<
[\w\W]
+>
)[^
>
]
*$|#
([\w\-]
+
)
$
)
/
,
// Check if a string has a non-whitespace character in it
// Check if a string has a non-whitespace character in it
rnotwhite
=
/
\S
/
,
rnotwhite
=
/
\S
/
,
...
@@ -93,76 +92,31 @@ jQuery.fn = jQuery.prototype = {
...
@@ -93,76 +92,31 @@ jQuery.fn = jQuery.prototype = {
return
this
;
return
this
;
}
}
// The body element only exists once, optimize finding it
if
(
selector
===
"body"
&&
!
context
&&
document
.
body
)
{
this
.
context
=
document
;
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
match
=
quickExpr
.
exec
(
selector
);
if
(
(
match
=
quickExpr
.
exec
(
selector
))
)
{
context
=
context
instanceof
jQuery
?
context
[
0
]
:
context
;
// Verify a match, and that no context was specified for #id
doc
=
(
context
?
context
.
ownerDocument
||
context
:
document
);
if
(
match
&&
(
match
[
1
]
||
!
context
)
)
{
// HANDLE: $(html) -> $(array)
if
(
match
[
1
]
)
{
context
=
context
instanceof
jQuery
?
context
[
0
]
:
context
;
doc
=
(
context
?
context
.
ownerDocument
||
context
:
document
);
// If a single string is passed in and it's a single tag
// just do a createElement and skip the rest
ret
=
rsingleTag
.
exec
(
selector
);
if
(
ret
)
{
// If a single string is passed in and it's a single tag
if
(
jQuery
.
isPlainObject
(
context
)
)
{
// just do a createElement and skip the rest
selector
=
[
document
.
createElement
(
ret
[
1
]
)
];
ret
=
rsingleTag
.
exec
(
selector
);
jQuery
.
fn
.
attr
.
call
(
selector
,
context
,
true
);
}
else
{
if
(
ret
)
{
selector
=
[
doc
.
createElement
(
ret
[
1
]
)
];
if
(
jQuery
.
isPlainObject
(
context
)
)
{
}
selector
=
[
document
.
createElement
(
ret
[
1
]
)
];
jQuery
.
fn
.
attr
.
call
(
selector
,
context
,
true
);
}
else
{
}
else
{
ret
=
jQuery
.
buildFragment
(
[
match
[
1
]
],
[
doc
]
);
selector
=
[
doc
.
createElement
(
ret
[
1
]
)
];
selector
=
(
ret
.
cacheable
?
jQuery
(
ret
.
fragment
).
clone
()[
0
]
:
ret
.
fragment
).
childNodes
;
}
}
return
jQuery
.
merge
(
this
,
selector
);
// HANDLE: $("#id")
}
else
{
}
else
{
elem
=
document
.
getElementById
(
match
[
2
]
);
ret
=
jQuery
.
buildFragment
(
[
match
[
1
]
],
[
doc
]
);
selector
=
(
ret
.
cacheable
?
jQuery
(
ret
.
fragment
).
clone
()[
0
]
:
ret
.
fragment
).
childNodes
;
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if
(
elem
&&
elem
.
parentNode
)
{
// Handle the case where IE and Opera return items
// by name instead of ID
if
(
elem
.
id
!==
match
[
2
]
)
{
return
rootjQuery
.
find
(
selector
);
}
// Otherwise, we inject the element directly into the jQuery object
this
.
length
=
1
;
this
[
0
]
=
elem
;
}
this
.
context
=
document
;
this
.
selector
=
selector
;
return
this
;
}
}
// HANDLE: $("TAG")
}
else
if
(
!
context
&&
!
rnonword
.
test
(
selector
)
)
{
this
.
selector
=
selector
;
this
.
context
=
document
;
selector
=
document
.
getElementsByTagName
(
selector
);
return
jQuery
.
merge
(
this
,
selector
);
return
jQuery
.
merge
(
this
,
selector
);
// HANDLE: $(expr, $(...))
// HANDLE: $(expr, $(...))
...
...
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