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
90647880
Commit
90647880
authored
Aug 25, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some bugs with the test suite and fixed a bug with setting attributes.
parent
7caca06c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
39 deletions
+35
-39
test.js
build/test/js/test.js
+1
-1
test.js
build/test/test.js
+9
-9
jquery.js
src/jquery/jquery.js
+25
-29
No files found.
build/test/js/test.js
View file @
90647880
...
@@ -4,7 +4,7 @@ function runTests(files) {
...
@@ -4,7 +4,7 @@ function runTests(files) {
function
runTest
(
files
,
num
)
{
function
runTest
(
files
,
num
)
{
$
.
get
(
files
[
num
],
function
(
js
){
$
.
get
(
files
[
num
],
function
(
js
){
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
);
js
=
js
.
replace
(
/</g
,
"<"
).
replace
(
/>/g
,
">"
)
.
replace
(
/&/g
,
"&"
)
;
try
{
try
{
eval
(
js
);
eval
(
js
);
...
...
build/test/test.js
View file @
90647880
...
@@ -4,16 +4,15 @@ var dir = arguments[1];
...
@@ -4,16 +4,15 @@ var dir = arguments[1];
var
indexFile
=
readFile
(
"build/test/index.html"
);
var
indexFile
=
readFile
(
"build/test/index.html"
);
var
testFile
=
readFile
(
"build/test/test.html"
);
var
testFile
=
readFile
(
"build/test/test.html"
);
var
files
=
{};
var
jq
=
parse
(
readFile
(
arguments
[
0
]
)
);
var
jq
=
parse
(
readFile
(
arguments
[
0
]
)
);
var
fileList
=
[];
var
count
=
1
;
for
(
var
i
=
0
;
i
<
jq
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
jq
.
length
;
i
++
)
{
if
(
jq
[
i
].
tests
.
length
>
0
)
{
if
(
jq
[
i
].
tests
.
length
>
0
)
{
var
name
=
count
+
"-"
+
jq
[
i
].
name
;
var
count
=
1
;
while
(
files
[
jq
[
i
].
name
+
count
]
)
{
count
++
;
}
var
name
=
jq
[
i
].
name
+
count
;
var
myFile
=
testFile
var
myFile
=
testFile
.
replace
(
/{TITLE}/g
,
jq
[
i
].
name
)
.
replace
(
/{TITLE}/g
,
jq
[
i
].
name
)
...
@@ -22,17 +21,18 @@ for ( var i = 0; i < jq.length; i++ ) {
...
@@ -22,17 +21,18 @@ for ( var i = 0; i < jq.length; i++ ) {
var
fileName
=
"tests/"
+
name
+
".js"
;
var
fileName
=
"tests/"
+
name
+
".js"
;
//writeFile( dir + "/" + fileName, myFile );
writeFile
(
dir
+
"/"
+
fileName
,
jq
[
i
].
tests
.
join
(
"
\n
"
)
);
writeFile
(
dir
+
"/"
+
fileName
,
jq
[
i
].
tests
.
join
(
"
\n
"
)
);
files
[
fileName
]
=
1
;
fileList
.
push
(
fileName
);
count
++
;
}
}
}
}
var
fileString
=
""
;
var
fileString
=
""
;
for
(
var
i
in
files
)
{
for
(
var
i
=
0
;
i
<
fileList
.
length
;
i
++
)
{
if
(
fileString
)
fileString
+=
", "
;
if
(
fileString
)
fileString
+=
", "
;
fileString
+=
"'"
+
i
+
"'"
;
fileString
+=
"'"
+
fileList
[
i
]
+
"'"
;
}
}
writeFile
(
dir
+
"/index.html"
,
indexFile
.
replace
(
/{FILES}/g
,
fileString
)
);
writeFile
(
dir
+
"/index.html"
,
indexFile
.
replace
(
/{FILES}/g
,
fileString
)
);
src/jquery/jquery.js
View file @
90647880
...
@@ -265,12 +265,10 @@ jQuery.fn = jQuery.prototype = {
...
@@ -265,12 +265,10 @@ jQuery.fn = jQuery.prototype = {
* @before <img/>
* @before <img/>
* @result <img src="test.jpg" alt="Test Image"/>
* @result <img src="test.jpg" alt="Test Image"/>
*
*
* @test var div = $("div");
* @test var pass = true;
* div.attr({foo: 'baz', zoo: 'ping'});
* $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
* var pass = true;
* if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
* for ( var i = 0; i < div.size(); i++ ) {
* });
* if ( div.get(i).foo != "baz" && div.get(i).zoo != "ping" ) pass = false;
* }
* ok( pass, "Set Multiple Attributes" );
* ok( pass, "Set Multiple Attributes" );
*
*
* @name attr
* @name attr
...
@@ -290,7 +288,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -290,7 +288,7 @@ jQuery.fn = jQuery.prototype = {
* div.attr("foo", "bar");
* div.attr("foo", "bar");
* var pass = true;
* var pass = true;
* for ( var i = 0; i < div.size(); i++ ) {
* for ( var i = 0; i < div.size(); i++ ) {
* if ( div.get(i).
foo
!= "bar" ) pass = false;
* if ( div.get(i).
getAttribute('foo')
!= "bar" ) pass = false;
* }
* }
* ok( pass, "Set Attribute" );
* ok( pass, "Set Attribute" );
*
*
...
@@ -1255,28 +1253,26 @@ jQuery.extend({
...
@@ -1255,28 +1253,26 @@ jQuery.extend({
return
r
;
return
r
;
},
},
attr
:
function
(
o
,
a
,
v
){
attr
:
function
(
elem
,
name
,
value
){
if
(
a
&&
a
.
constructor
==
String
)
{
var
fix
=
{
var
fix
=
{
"for"
:
"htmlFor"
,
"for"
:
"htmlFor"
,
"class"
:
"className"
,
"class"
:
"className"
,
"float"
:
"cssFloat"
,
"float"
:
"cssFloat"
innerHTML
:
"innerHTML"
,
};
className
:
"className"
};
a
=
(
fix
[
a
]
&&
fix
[
a
].
replace
&&
fix
[
a
]
||
a
)
.
replace
(
/-
([
a-z
])
/ig
,
function
(
z
,
b
){
if
(
fix
[
name
]
)
{
return
b
.
toUpperCase
();
if
(
value
!=
undefined
)
elem
[
fix
[
name
]]
=
value
;
});
return
elem
[
fix
[
name
]];
}
else
if
(
elem
.
getAttribute
)
{
if
(
v
!=
undefined
)
{
if
(
value
!=
undefined
)
elem
.
setAttribute
(
name
,
value
);
o
[
a
]
=
v
;
return
elem
.
getAttribute
(
name
,
2
);
if
(
o
.
setAttribute
&&
a
!=
"disabled"
)
}
else
{
o
.
setAttribute
(
a
,
v
);
name
=
name
.
replace
(
/-
([
a-z
])
/ig
,
function
(
z
,
b
){
return
b
.
toUpperCase
();});
}
if
(
value
!=
undefined
)
elem
[
name
]
=
value
;
return
elem
[
name
];
return
o
[
a
]
||
o
.
getAttribute
&&
o
.
getAttribute
(
a
)
||
""
;
}
}
else
return
""
;
},
},
// The regular expressions that power the parsing engine
// The regular expressions that power the parsing engine
...
...
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