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
1a4d1904
Commit
1a4d1904
authored
Dec 10, 2009
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up whitespace and a couple of glitches.
parent
b3cee018
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
44 deletions
+37
-44
attributes.js
src/attributes.js
+13
-20
core.js
src/core.js
+3
-3
manipulation.js
src/manipulation.js
+5
-5
attributes.js
test/unit/attributes.js
+10
-10
manipulation.js
test/unit/manipulation.js
+6
-6
No files found.
src/attributes.js
View file @
1a4d1904
...
@@ -4,11 +4,11 @@ jQuery.fn.extend({
...
@@ -4,11 +4,11 @@ jQuery.fn.extend({
},
},
addClass
:
function
(
value
)
{
addClass
:
function
(
value
)
{
if
(
jQuery
.
isFunction
(
value
))
{
if
(
jQuery
.
isFunction
(
value
))
{
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
jQuery
(
this
).
addClass
(
value
.
call
(
this
)
);
jQuery
(
this
).
addClass
(
value
.
call
(
this
)
);
});
});
}
}
if
(
value
&&
typeof
value
===
"string"
)
{
if
(
value
&&
typeof
value
===
"string"
)
{
var
classNames
=
(
value
||
""
).
split
(
/
\s
+/
);
var
classNames
=
(
value
||
""
).
split
(
/
\s
+/
);
...
@@ -35,11 +35,11 @@ jQuery.fn.extend({
...
@@ -35,11 +35,11 @@ jQuery.fn.extend({
},
},
removeClass
:
function
(
value
)
{
removeClass
:
function
(
value
)
{
if
(
jQuery
.
isFunction
(
value
))
{
if
(
jQuery
.
isFunction
(
value
))
{
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
jQuery
(
this
).
removeClass
(
value
.
call
(
this
)
);
jQuery
(
this
).
removeClass
(
value
.
call
(
this
)
);
});
});
}
}
if
(
(
value
&&
typeof
value
===
"string"
)
||
value
===
undefined
)
{
if
(
(
value
&&
typeof
value
===
"string"
)
||
value
===
undefined
)
{
var
classNames
=
(
value
||
""
).
split
(
/
\s
+/
);
var
classNames
=
(
value
||
""
).
split
(
/
\s
+/
);
...
@@ -170,13 +170,6 @@ jQuery.each({
...
@@ -170,13 +170,6 @@ jQuery.each({
},
},
toggleClass
:
function
(
classNames
,
state
)
{
toggleClass
:
function
(
classNames
,
state
)
{
if
(
jQuery
.
isFunction
(
classNames
)
)
{
return
this
.
each
(
function
()
{
console
.
log
(
this
);
jQuery
(
this
).
toggleClass
(
classNames
.
call
(
this
),
state
);
});
}
var
type
=
typeof
classNames
;
var
type
=
typeof
classNames
;
if
(
type
===
"string"
)
{
if
(
type
===
"string"
)
{
// toggle individual class names
// toggle individual class names
...
@@ -198,9 +191,9 @@ jQuery.each({
...
@@ -198,9 +191,9 @@ jQuery.each({
}
}
},
function
(
name
,
fn
){
},
function
(
name
,
fn
){
jQuery
.
fn
[
name
]
=
function
(
val
,
state
){
jQuery
.
fn
[
name
]
=
function
(
val
,
state
){
if
(
jQuery
.
isFunction
(
val
)
)
{
if
(
jQuery
.
isFunction
(
val
)
)
{
return
this
.
each
(
function
()
{
jQuery
(
this
)[
name
](
val
.
call
(
this
),
state
);
});
return
this
.
each
(
function
()
{
jQuery
(
this
)[
name
](
val
.
call
(
this
),
state
);
});
}
}
return
this
.
each
(
fn
,
arguments
);
return
this
.
each
(
fn
,
arguments
);
};
};
...
...
src/core.js
View file @
1a4d1904
...
@@ -444,8 +444,8 @@ jQuery.extend({
...
@@ -444,8 +444,8 @@ jQuery.extend({
// not own constructor property must be Object
// not own constructor property must be Object
if
(
obj
.
constructor
if
(
obj
.
constructor
&&
!
hasOwnProperty
.
call
(
obj
,
"constructor"
)
&&
!
hasOwnProperty
.
call
(
obj
,
"constructor"
)
&&
!
hasOwnProperty
.
call
(
obj
.
constructor
.
prototype
,
"isPrototypeOf"
)
)
{
&&
!
hasOwnProperty
.
call
(
obj
.
constructor
.
prototype
,
"isPrototypeOf"
)
)
{
return
false
;
return
false
;
}
}
...
@@ -481,7 +481,7 @@ jQuery.extend({
...
@@ -481,7 +481,7 @@ jQuery.extend({
script
.
text
=
data
;
script
.
text
=
data
;
}
}
// Use insertBefore instead of appendChild
to circumvent an IE6 bug.
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
// This arises when a base node is used (#2709).
// This arises when a base node is used (#2709).
head
.
insertBefore
(
script
,
head
.
firstChild
);
head
.
insertBefore
(
script
,
head
.
firstChild
);
head
.
removeChild
(
script
);
head
.
removeChild
(
script
);
...
...
src/manipulation.js
View file @
1a4d1904
...
@@ -32,11 +32,11 @@ if ( !jQuery.support.htmlSerialize ) {
...
@@ -32,11 +32,11 @@ if ( !jQuery.support.htmlSerialize ) {
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
text
:
function
(
text
)
{
text
:
function
(
text
)
{
if
(
jQuery
.
isFunction
(
text
))
{
if
(
jQuery
.
isFunction
(
text
))
{
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
return
jQuery
(
this
).
text
(
text
.
call
(
this
)
);
return
jQuery
(
this
).
text
(
text
.
call
(
this
)
);
});
});
}
}
if
(
typeof
text
!==
"object"
&&
text
!==
undefined
)
{
if
(
typeof
text
!==
"object"
&&
text
!==
undefined
)
{
return
this
.
empty
().
append
(
(
this
[
0
]
&&
this
[
0
].
ownerDocument
||
document
).
createTextNode
(
text
)
);
return
this
.
empty
().
append
(
(
this
[
0
]
&&
this
[
0
].
ownerDocument
||
document
).
createTextNode
(
text
)
);
...
...
test/unit/attributes.js
View file @
1a4d1904
...
@@ -81,8 +81,8 @@ test("attr(Hash)", function() {
...
@@ -81,8 +81,8 @@ test("attr(Hash)", function() {
if
(
this
.
getAttribute
(
'foo'
)
!=
"baz"
&&
this
.
getAttribute
(
'zoo'
)
!=
"ping"
)
pass
=
false
;
if
(
this
.
getAttribute
(
'foo'
)
!=
"baz"
&&
this
.
getAttribute
(
'zoo'
)
!=
"ping"
)
pass
=
false
;
});
});
ok
(
pass
,
"Set Multiple Attributes"
);
ok
(
pass
,
"Set Multiple Attributes"
);
equals
(
jQuery
(
'#text1'
).
attr
({
'value'
:
function
()
{
return
this
.
id
;
}})[
0
].
value
,
"text1"
,
"Set attribute to computed value #1"
);
equals
(
jQuery
(
'#text1'
).
attr
({
'value'
:
function
()
{
return
this
.
id
;
}})[
0
].
value
,
"text1"
,
"Set attribute to computed value #1"
);
equals
(
jQuery
(
'#text1'
).
attr
({
'title'
:
function
(
i
)
{
return
i
;
}}).
attr
(
'title'
),
"0"
,
"Set attribute to computed value #2"
);
equals
(
jQuery
(
'#text1'
).
attr
({
'title'
:
function
(
i
)
{
return
i
;
}}).
attr
(
'title'
),
"0"
,
"Set attribute to computed value #2"
);
});
});
...
@@ -314,11 +314,11 @@ var testAddClass = function(valueObj) {
...
@@ -314,11 +314,11 @@ var testAddClass = function(valueObj) {
}
}
test
(
"addClass(String)"
,
function
()
{
test
(
"addClass(String)"
,
function
()
{
testAddClass
(
bareObj
);
testAddClass
(
bareObj
);
});
});
test
(
"addClass(Function)"
,
function
()
{
test
(
"addClass(Function)"
,
function
()
{
testAddClass
(
functionReturningObj
);
testAddClass
(
functionReturningObj
);
});
});
var
testRemoveClass
=
function
(
valueObj
)
{
var
testRemoveClass
=
function
(
valueObj
)
{
...
@@ -355,11 +355,11 @@ var testRemoveClass = function(valueObj) {
...
@@ -355,11 +355,11 @@ var testRemoveClass = function(valueObj) {
};
};
test
(
"removeClass(String) - simple"
,
function
()
{
test
(
"removeClass(String) - simple"
,
function
()
{
testRemoveClass
(
bareObj
);
testRemoveClass
(
bareObj
);
});
});
test
(
"removeClass(Function) - simple"
,
function
()
{
test
(
"removeClass(Function) - simple"
,
function
()
{
testRemoveClass
(
functionReturningObj
);
testRemoveClass
(
functionReturningObj
);
});
});
var
testToggleClass
=
function
(
valueObj
)
{
var
testToggleClass
=
function
(
valueObj
)
{
...
@@ -415,11 +415,11 @@ var testToggleClass = function(valueObj) {
...
@@ -415,11 +415,11 @@ var testToggleClass = function(valueObj) {
};
};
test
(
"toggleClass(String|boolean|undefined[, boolean])"
,
function
()
{
test
(
"toggleClass(String|boolean|undefined[, boolean])"
,
function
()
{
testToggleClass
(
bareObj
);
testToggleClass
(
bareObj
);
});
});
test
(
"toggleClass(Function[, boolean])"
,
function
()
{
test
(
"toggleClass(Function[, boolean])"
,
function
()
{
testToggleClass
(
functionReturningObj
);
testToggleClass
(
functionReturningObj
);
});
});
var
testRemoveAttr
=
function
(
valueObj
)
{
var
testRemoveAttr
=
function
(
valueObj
)
{
...
@@ -428,11 +428,11 @@ var testRemoveAttr = function(valueObj) {
...
@@ -428,11 +428,11 @@ var testRemoveAttr = function(valueObj) {
};
};
test
(
"removeAttr(String)"
,
function
()
{
test
(
"removeAttr(String)"
,
function
()
{
testRemoveAttr
(
bareObj
);
testRemoveAttr
(
bareObj
);
});
});
test
(
"removeAttr(Function)"
,
function
()
{
test
(
"removeAttr(Function)"
,
function
()
{
testRemoveAttr
(
functionReturningObj
);
testRemoveAttr
(
functionReturningObj
);
});
});
test
(
"addClass, removeClass, hasClass"
,
function
()
{
test
(
"addClass, removeClass, hasClass"
,
function
()
{
...
...
test/unit/manipulation.js
View file @
1a4d1904
...
@@ -105,7 +105,7 @@ test("wrapAll(String|Element)", function() {
...
@@ -105,7 +105,7 @@ test("wrapAll(String|Element)", function() {
// TODO: Figure out why each(wrapAll) is not equivalent to wrapAll
// TODO: Figure out why each(wrapAll) is not equivalent to wrapAll
// test("wrapAll(Function)", function() {
// test("wrapAll(Function)", function() {
//
testWrapAll(functionReturningObj);
// testWrapAll(functionReturningObj);
// })
// })
var
testWrapInner
=
function
(
val
)
{
var
testWrapInner
=
function
(
val
)
{
...
@@ -130,7 +130,7 @@ test("wrapInner(String|Element)", function() {
...
@@ -130,7 +130,7 @@ test("wrapInner(String|Element)", function() {
// TODO: wrapInner uses wrapAll -- get wrapAll working with Function
// TODO: wrapInner uses wrapAll -- get wrapAll working with Function
// test("wrapInner(Function)", function() {
// test("wrapInner(Function)", function() {
//
testWrapInner(functionReturningObj)
// testWrapInner(functionReturningObj)
// })
// })
var
testUnwrap
=
function
()
{
var
testUnwrap
=
function
()
{
...
@@ -251,7 +251,7 @@ var testAppend = function(valueObj) {
...
@@ -251,7 +251,7 @@ var testAppend = function(valueObj) {
}
}
test
(
"append(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"append(String|Element|Array<Element>|jQuery)"
,
function
()
{
testAppend
(
bareObj
);
testAppend
(
bareObj
);
});
});
test
(
"append(Function)"
,
function
()
{
test
(
"append(Function)"
,
function
()
{
...
@@ -658,9 +658,9 @@ var testVal = function(valueObj) {
...
@@ -658,9 +658,9 @@ var testVal = function(valueObj) {
jQuery
(
"#select1"
).
val
(
valueObj
(
2
));
jQuery
(
"#select1"
).
val
(
valueObj
(
2
));
equals
(
jQuery
(
"#select1"
).
val
(),
"2"
,
"Check for modified (via val(Number)) value of select element"
);
equals
(
jQuery
(
"#select1"
).
val
(),
"2"
,
"Check for modified (via val(Number)) value of select element"
);
jQuery
(
"#select1"
).
append
(
"<option value='4'>four</option>"
);
jQuery
(
"#select1"
).
append
(
"<option value='4'>four</option>"
);
jQuery
(
"#select1"
).
val
(
valueObj
(
4
));
jQuery
(
"#select1"
).
val
(
valueObj
(
4
));
equals
(
jQuery
(
"#select1"
).
val
(),
"4"
,
"Should be possible to set the val() to a newly created option"
);
equals
(
jQuery
(
"#select1"
).
val
(),
"4"
,
"Should be possible to set the val() to a newly created option"
);
// using contents will get comments regular, text, and comment nodes
// using contents will get comments regular, text, and comment nodes
var
j
=
jQuery
(
"#nonnodes"
).
contents
();
var
j
=
jQuery
(
"#nonnodes"
).
contents
();
...
...
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