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
8e105ef9
Commit
8e105ef9
authored
Jan 22, 2007
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added in jQuery.nodeName() to simplify checking nodeName constantly.
parent
d2f9022a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
jquery.js
src/jquery/jquery.js
+7
-3
selector.js
src/selector/selector.js
+5
-5
No files found.
src/jquery/jquery.js
View file @
8e105ef9
...
@@ -1100,7 +1100,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -1100,7 +1100,7 @@ jQuery.fn = jQuery.prototype = {
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
var
obj
=
this
;
var
obj
=
this
;
if
(
table
&&
this
.
nodeName
.
toUpperCase
()
==
"TABLE"
&&
a
[
0
].
nodeName
.
toUpperCase
()
==
"TR"
)
if
(
table
&&
jQuery
.
nodeName
(
this
,
"table"
)
&&
jQuery
.
nodeName
(
a
[
0
],
"tr"
)
)
obj
=
this
.
getElementsByTagName
(
"tbody"
)[
0
]
||
this
.
appendChild
(
document
.
createElement
(
"tbody"
));
obj
=
this
.
getElementsByTagName
(
"tbody"
)[
0
]
||
this
.
appendChild
(
document
.
createElement
(
"tbody"
));
jQuery
.
each
(
a
,
function
(){
jQuery
.
each
(
a
,
function
(){
...
@@ -1229,6 +1229,10 @@ jQuery.extend({
...
@@ -1229,6 +1229,10 @@ jQuery.extend({
typeof
fn
[
0
]
==
"undefined"
&&
/function/i
.
test
(
fn
+
""
);
typeof
fn
[
0
]
==
"undefined"
&&
/function/i
.
test
(
fn
+
""
);
},
},
nodeName
:
function
(
elem
,
name
)
{
return
elem
.
nodeName
&&
elem
.
nodeName
.
toUpperCase
()
==
name
.
toUpperCase
();
},
/**
/**
* A generic iterator function, which can be used to seemlessly
* A generic iterator function, which can be used to seemlessly
* iterate over both objects and arrays. This function is not the same
* iterate over both objects and arrays. This function is not the same
...
@@ -1451,7 +1455,7 @@ jQuery.extend({
...
@@ -1451,7 +1455,7 @@ jQuery.extend({
tb
=
div
.
childNodes
;
tb
=
div
.
childNodes
;
for
(
var
n
=
tb
.
length
-
1
;
n
>=
0
;
--
n
)
for
(
var
n
=
tb
.
length
-
1
;
n
>=
0
;
--
n
)
if
(
tb
[
n
].
nodeName
.
toUpperCase
()
==
"TBODY"
&&
!
tb
[
n
].
childNodes
.
length
)
if
(
jQuery
.
nodeName
(
tb
[
n
],
"tbody"
)
&&
!
tb
[
n
].
childNodes
.
length
)
tb
[
n
].
parentNode
.
removeChild
(
tb
[
n
]);
tb
[
n
].
parentNode
.
removeChild
(
tb
[
n
]);
}
}
...
@@ -1510,7 +1514,7 @@ jQuery.extend({
...
@@ -1510,7 +1514,7 @@ jQuery.extend({
if
(
value
!=
undefined
)
elem
[
fix
[
name
]]
=
value
;
if
(
value
!=
undefined
)
elem
[
fix
[
name
]]
=
value
;
return
elem
[
fix
[
name
]];
return
elem
[
fix
[
name
]];
}
else
if
(
value
==
undefined
&&
jQuery
.
browser
.
msie
&&
elem
.
nodeName
&&
elem
.
nodeName
.
toUpperCase
()
==
"FORM"
&&
(
name
==
"action"
||
name
==
"method"
)
)
}
else
if
(
value
==
undefined
&&
jQuery
.
browser
.
msie
&&
jQuery
.
nodeName
(
elem
,
"form"
)
&&
(
name
==
"action"
||
name
==
"method"
)
)
return
elem
.
getAttributeNode
(
name
).
nodeValue
;
return
elem
.
getAttributeNode
(
name
).
nodeValue
;
// IE elem.getAttribute passes even for style
// IE elem.getAttribute passes even for style
...
...
src/selector/selector.js
View file @
8e105ef9
jQuery
.
extend
({
jQuery
.
extend
({
expr
:
{
expr
:
{
""
:
"m[2]=='*'||
a.nodeName.toUpperCase()==m[2].toUpperCase(
)"
,
""
:
"m[2]=='*'||
jQuery.nodeName(a,m[2]
)"
,
"#"
:
"a.getAttribute('id')==m[2]"
,
"#"
:
"a.getAttribute('id')==m[2]"
,
":"
:
{
":"
:
{
// Position Checks
// Position Checks
...
@@ -45,7 +45,7 @@ jQuery.extend({
...
@@ -45,7 +45,7 @@ jQuery.extend({
submit
:
"a.type=='submit'"
,
submit
:
"a.type=='submit'"
,
image
:
"a.type=='image'"
,
image
:
"a.type=='image'"
,
reset
:
"a.type=='reset'"
,
reset
:
"a.type=='reset'"
,
button
:
'a.type=="button"||
a.nodeName.toUpperCase()=="BUTTON"
'
,
button
:
'a.type=="button"||
jQuery.nodeName(a,"button")
'
,
input
:
"/input|select|textarea|button/i.test(a.nodeName)"
input
:
"/input|select|textarea|button/i.test(a.nodeName)"
},
},
"."
:
"jQuery.className.has(a,m[2])"
,
"."
:
"jQuery.className.has(a,m[2])"
,
...
@@ -155,7 +155,7 @@ jQuery.extend({
...
@@ -155,7 +155,7 @@ jQuery.extend({
// Perform our own iteration and filter
// Perform our own iteration and filter
jQuery
.
each
(
ret
,
function
(){
jQuery
.
each
(
ret
,
function
(){
for
(
var
c
=
this
.
firstChild
;
c
;
c
=
c
.
nextSibling
)
for
(
var
c
=
this
.
firstChild
;
c
;
c
=
c
.
nextSibling
)
if
(
c
.
nodeType
==
1
&&
(
c
.
nodeName
.
toUpperCase
()
==
m
[
1
].
toUpperCase
(
)
||
m
[
1
]
==
"*"
)
)
if
(
c
.
nodeType
==
1
&&
(
jQuery
.
nodeName
(
c
,
m
[
1
]
)
||
m
[
1
]
==
"*"
)
)
r
.
push
(
c
);
r
.
push
(
c
);
});
});
...
@@ -227,7 +227,7 @@ jQuery.extend({
...
@@ -227,7 +227,7 @@ jQuery.extend({
// Do a quick check for node name (where applicable) so
// Do a quick check for node name (where applicable) so
// that div#foo searches will be really fast
// that div#foo searches will be really fast
ret
=
r
=
oid
&&
ret
=
r
=
oid
&&
(
!
m
[
3
]
||
oid
.
nodeName
.
toUpperCase
()
==
m
[
3
].
toUpperCase
(
))
?
[
oid
]
:
[];
(
!
m
[
3
]
||
jQuery
.
nodeName
(
oid
,
m
[
3
]
))
?
[
oid
]
:
[];
}
else
{
}
else
{
// Pre-compile a regular expression to handle class searches
// Pre-compile a regular expression to handle class searches
...
@@ -242,7 +242,7 @@ jQuery.extend({
...
@@ -242,7 +242,7 @@ jQuery.extend({
var
tag
=
m
[
1
]
!=
""
||
m
[
0
]
==
""
?
"*"
:
m
[
2
];
var
tag
=
m
[
1
]
!=
""
||
m
[
0
]
==
""
?
"*"
:
m
[
2
];
// Handle IE7 being really dumb about <object>s
// Handle IE7 being really dumb about <object>s
if
(
this
.
nodeName
.
toUpperCase
()
==
"OBJECT"
&&
tag
==
"*"
)
if
(
jQuery
.
nodeName
(
this
,
"object"
)
&&
tag
==
"*"
)
tag
=
"param"
;
tag
=
"param"
;
jQuery
.
merge
(
r
,
jQuery
.
merge
(
r
,
...
...
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