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
ef819c91
Commit
ef819c91
authored
Nov 25, 2009
by
Mark Gibson
Committed by
John Resig
Nov 25, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing endlines.
parent
0bb3998a
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
590 additions
and
590 deletions
+590
-590
data.js
src/data.js
+170
-170
json.php
test/data/json.php
+8
-8
jsonp.php
test/data/jsonp.php
+10
-10
name.php
test/data/name.php
+28
-28
params_html.php
test/data/params_html.php
+11
-11
test.js
test/data/test.js
+3
-3
polluted.php
test/polluted.php
+64
-64
data.js
test/unit/data.js
+296
-296
No files found.
src/data.js
View file @
ef819c91
var
expando
=
"jQuery"
+
now
(),
uuid
=
0
,
windowData
=
{};
var
emptyObject
=
{};
jQuery
.
extend
({
cache
:
{},
expando
:
expando
,
data
:
function
(
elem
,
name
,
data
)
{
elem
=
elem
==
window
?
windowData
:
elem
;
var
id
=
elem
[
expando
],
cache
=
jQuery
.
cache
,
thisCache
;
// Handle the case where there's no name immediately
if
(
!
name
&&
!
id
)
{
return
null
;
}
// Compute a unique ID for the element
if
(
!
id
)
{
id
=
++
uuid
;
}
// Avoid generating a new cache unless none exists and we
// want to manipulate it.
if
(
cache
[
id
]
)
{
thisCache
=
cache
[
id
];
}
else
if
(
typeof
data
===
"undefined"
)
{
thisCache
=
emptyObject
;
}
else
{
thisCache
=
cache
[
id
]
=
{};
}
// Prevent overriding the named cache with undefined values
if
(
data
!==
undefined
)
{
elem
[
expando
]
=
id
;
thisCache
[
name
]
=
data
;
}
return
name
?
thisCache
[
name
]
:
thisCache
;
},
removeData
:
function
(
elem
,
name
)
{
elem
=
elem
==
window
?
windowData
:
elem
;
var
id
=
elem
[
expando
],
cache
=
jQuery
.
cache
,
thisCache
=
cache
[
id
];
// If we want to remove a specific section of the element's data
if
(
name
)
{
if
(
thisCache
)
{
// Remove the section of cache data
delete
thisCache
[
name
];
// If we've removed all the data, remove the element's cache
if
(
jQuery
.
isEmptyObject
(
thisCache
)
)
{
jQuery
.
removeData
(
elem
);
}
}
// Otherwise, we want to remove all of the element's data
}
else
{
// Clean up the element expando
try
{
delete
elem
[
expando
];
}
catch
(
e
)
{
// IE has trouble directly removing the expando
// but it's ok with using removeAttribute
if
(
elem
.
removeAttribute
)
{
elem
.
removeAttribute
(
expando
);
}
}
// Completely remove the data cache
delete
cache
[
id
];
}
},
queue
:
function
(
elem
,
type
,
data
)
{
if
(
!
elem
)
return
;
type
=
(
type
||
"fx"
)
+
"queue"
;
var
q
=
jQuery
.
data
(
elem
,
type
);
// Speed up dequeue by getting out quickly if this is just a lookup
if
(
!
data
)
return
q
||
[];
if
(
!
q
||
jQuery
.
isArray
(
data
)
)
q
=
jQuery
.
data
(
elem
,
type
,
jQuery
.
makeArray
(
data
)
);
else
q
.
push
(
data
);
return
q
;
},
dequeue
:
function
(
elem
,
type
){
type
=
type
||
"fx"
;
var
queue
=
jQuery
.
queue
(
elem
,
type
),
fn
=
queue
.
shift
();
// If the fx queue is dequeued, always remove the progress sentinel
if
(
fn
===
"inprogress"
)
fn
=
queue
.
shift
();
if
(
fn
)
{
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if
(
type
==
"fx"
)
queue
.
unshift
(
"inprogress"
);
fn
.
call
(
elem
,
function
()
{
jQuery
.
dequeue
(
elem
,
type
);
});
}
}
});
jQuery
.
fn
.
extend
({
data
:
function
(
key
,
value
){
if
(
typeof
key
===
"undefined"
&&
this
.
length
)
{
return
jQuery
.
data
(
this
[
0
]
);
}
var
parts
=
key
.
split
(
"."
);
parts
[
1
]
=
parts
[
1
]
?
"."
+
parts
[
1
]
:
""
;
if
(
value
===
undefined
)
{
var
data
=
this
.
triggerHandler
(
"getData"
+
parts
[
1
]
+
"!"
,
[
parts
[
0
]]);
if
(
data
===
undefined
&&
this
.
length
)
data
=
jQuery
.
data
(
this
[
0
],
key
);
return
data
===
undefined
&&
parts
[
1
]
?
this
.
data
(
parts
[
0
]
)
:
data
;
}
else
return
this
.
trigger
(
"setData"
+
parts
[
1
]
+
"!"
,
[
parts
[
0
],
value
]).
each
(
function
(){
jQuery
.
data
(
this
,
key
,
value
);
});
},
removeData
:
function
(
key
){
return
this
.
each
(
function
(){
jQuery
.
removeData
(
this
,
key
);
});
},
queue
:
function
(
type
,
data
){
if
(
typeof
type
!==
"string"
)
{
data
=
type
;
type
=
"fx"
;
}
if
(
data
===
undefined
)
return
jQuery
.
queue
(
this
[
0
],
type
);
return
this
.
each
(
function
(
i
,
elem
){
var
queue
=
jQuery
.
queue
(
this
,
type
,
data
);
if
(
type
==
"fx"
&&
queue
[
0
]
!==
"inprogress"
)
jQuery
.
dequeue
(
this
,
type
)
});
},
dequeue
:
function
(
type
){
return
this
.
each
(
function
(){
jQuery
.
dequeue
(
this
,
type
);
});
},
clearQueue
:
function
(
type
){
return
this
.
queue
(
type
||
"fx"
,
[]
);
}
});
var
expando
=
"jQuery"
+
now
(),
uuid
=
0
,
windowData
=
{};
var
emptyObject
=
{};
jQuery
.
extend
({
cache
:
{},
expando
:
expando
,
data
:
function
(
elem
,
name
,
data
)
{
elem
=
elem
==
window
?
windowData
:
elem
;
var
id
=
elem
[
expando
],
cache
=
jQuery
.
cache
,
thisCache
;
// Handle the case where there's no name immediately
if
(
!
name
&&
!
id
)
{
return
null
;
}
// Compute a unique ID for the element
if
(
!
id
)
{
id
=
++
uuid
;
}
// Avoid generating a new cache unless none exists and we
// want to manipulate it.
if
(
cache
[
id
]
)
{
thisCache
=
cache
[
id
];
}
else
if
(
typeof
data
===
"undefined"
)
{
thisCache
=
emptyObject
;
}
else
{
thisCache
=
cache
[
id
]
=
{};
}
// Prevent overriding the named cache with undefined values
if
(
data
!==
undefined
)
{
elem
[
expando
]
=
id
;
thisCache
[
name
]
=
data
;
}
return
name
?
thisCache
[
name
]
:
thisCache
;
},
removeData
:
function
(
elem
,
name
)
{
elem
=
elem
==
window
?
windowData
:
elem
;
var
id
=
elem
[
expando
],
cache
=
jQuery
.
cache
,
thisCache
=
cache
[
id
];
// If we want to remove a specific section of the element's data
if
(
name
)
{
if
(
thisCache
)
{
// Remove the section of cache data
delete
thisCache
[
name
];
// If we've removed all the data, remove the element's cache
if
(
jQuery
.
isEmptyObject
(
thisCache
)
)
{
jQuery
.
removeData
(
elem
);
}
}
// Otherwise, we want to remove all of the element's data
}
else
{
// Clean up the element expando
try
{
delete
elem
[
expando
];
}
catch
(
e
)
{
// IE has trouble directly removing the expando
// but it's ok with using removeAttribute
if
(
elem
.
removeAttribute
)
{
elem
.
removeAttribute
(
expando
);
}
}
// Completely remove the data cache
delete
cache
[
id
];
}
},
queue
:
function
(
elem
,
type
,
data
)
{
if
(
!
elem
)
return
;
type
=
(
type
||
"fx"
)
+
"queue"
;
var
q
=
jQuery
.
data
(
elem
,
type
);
// Speed up dequeue by getting out quickly if this is just a lookup
if
(
!
data
)
return
q
||
[];
if
(
!
q
||
jQuery
.
isArray
(
data
)
)
q
=
jQuery
.
data
(
elem
,
type
,
jQuery
.
makeArray
(
data
)
);
else
q
.
push
(
data
);
return
q
;
},
dequeue
:
function
(
elem
,
type
){
type
=
type
||
"fx"
;
var
queue
=
jQuery
.
queue
(
elem
,
type
),
fn
=
queue
.
shift
();
// If the fx queue is dequeued, always remove the progress sentinel
if
(
fn
===
"inprogress"
)
fn
=
queue
.
shift
();
if
(
fn
)
{
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if
(
type
==
"fx"
)
queue
.
unshift
(
"inprogress"
);
fn
.
call
(
elem
,
function
()
{
jQuery
.
dequeue
(
elem
,
type
);
});
}
}
});
jQuery
.
fn
.
extend
({
data
:
function
(
key
,
value
){
if
(
typeof
key
===
"undefined"
&&
this
.
length
)
{
return
jQuery
.
data
(
this
[
0
]
);
}
var
parts
=
key
.
split
(
"."
);
parts
[
1
]
=
parts
[
1
]
?
"."
+
parts
[
1
]
:
""
;
if
(
value
===
undefined
)
{
var
data
=
this
.
triggerHandler
(
"getData"
+
parts
[
1
]
+
"!"
,
[
parts
[
0
]]);
if
(
data
===
undefined
&&
this
.
length
)
data
=
jQuery
.
data
(
this
[
0
],
key
);
return
data
===
undefined
&&
parts
[
1
]
?
this
.
data
(
parts
[
0
]
)
:
data
;
}
else
return
this
.
trigger
(
"setData"
+
parts
[
1
]
+
"!"
,
[
parts
[
0
],
value
]).
each
(
function
(){
jQuery
.
data
(
this
,
key
,
value
);
});
},
removeData
:
function
(
key
){
return
this
.
each
(
function
(){
jQuery
.
removeData
(
this
,
key
);
});
},
queue
:
function
(
type
,
data
){
if
(
typeof
type
!==
"string"
)
{
data
=
type
;
type
=
"fx"
;
}
if
(
data
===
undefined
)
return
jQuery
.
queue
(
this
[
0
],
type
);
return
this
.
each
(
function
(
i
,
elem
){
var
queue
=
jQuery
.
queue
(
this
,
type
,
data
);
if
(
type
==
"fx"
&&
queue
[
0
]
!==
"inprogress"
)
jQuery
.
dequeue
(
this
,
type
)
});
},
dequeue
:
function
(
type
){
return
this
.
each
(
function
(){
jQuery
.
dequeue
(
this
,
type
);
});
},
clearQueue
:
function
(
type
){
return
this
.
queue
(
type
||
"fx"
,
[]
);
}
});
test/data/json.php
View file @
ef819c91
<?php
error_reporting
(
0
);
$json
=
$_REQUEST
[
'json'
];
if
(
$json
)
{
echo
'[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]'
;
}
else
{
echo
'{ "data": {"lang": "en", "length": 25} }'
;
}
<?php
error_reporting
(
0
);
$json
=
$_REQUEST
[
'json'
];
if
(
$json
)
{
echo
'[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]'
;
}
else
{
echo
'{ "data": {"lang": "en", "length": 25} }'
;
}
?>
\ No newline at end of file
test/data/jsonp.php
View file @
ef819c91
<?php
error_reporting
(
0
);
$callback
=
$_REQUEST
[
'callback'
];
$json
=
$_REQUEST
[
'json'
];
if
(
$json
)
{
echo
$callback
.
'([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])'
;
}
else
{
echo
$callback
.
'({ "data": {"lang": "en", "length": 25} })'
;
}
?>
<?php
error_reporting
(
0
);
$callback
=
$_REQUEST
[
'callback'
];
$json
=
$_REQUEST
[
'json'
];
if
(
$json
)
{
echo
$callback
.
'([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])'
;
}
else
{
echo
$callback
.
'({ "data": {"lang": "en", "length": 25} })'
;
}
?>
test/data/name.php
View file @
ef819c91
<?php
error_reporting
(
0
);
$wait
=
$_REQUEST
[
'wait'
];
if
(
$wait
)
{
sleep
(
$wait
);
}
$xml
=
$_REQUEST
[
'xml'
];
if
(
$xml
)
{
header
(
"Content-type: text/xml"
);
$result
=
(
$xml
==
"5-2"
)
?
"3"
:
"?"
;
echo
"<math><calculation>
$xml
</calculation><result>
$result
</result></math>"
;
die
();
}
$name
=
$_REQUEST
[
'name'
];
if
(
$name
==
'foo'
)
{
echo
"bar"
;
die
();
}
else
if
(
$name
==
'peter'
)
{
echo
"pan"
;
die
();
}
$request
=
apache_request_headers
();
$request
=
$request
[
'X-Custom-Header'
];
if
(
strlen
(
$request
)
>
0
)
{
echo
$request
;
die
();
}
echo
'ERROR <script type="text/javascript">ok( true, "name.php executed" );</script>'
;
<?php
error_reporting
(
0
);
$wait
=
$_REQUEST
[
'wait'
];
if
(
$wait
)
{
sleep
(
$wait
);
}
$xml
=
$_REQUEST
[
'xml'
];
if
(
$xml
)
{
header
(
"Content-type: text/xml"
);
$result
=
(
$xml
==
"5-2"
)
?
"3"
:
"?"
;
echo
"<math><calculation>
$xml
</calculation><result>
$result
</result></math>"
;
die
();
}
$name
=
$_REQUEST
[
'name'
];
if
(
$name
==
'foo'
)
{
echo
"bar"
;
die
();
}
else
if
(
$name
==
'peter'
)
{
echo
"pan"
;
die
();
}
$request
=
apache_request_headers
();
$request
=
$request
[
'X-Custom-Header'
];
if
(
strlen
(
$request
)
>
0
)
{
echo
$request
;
die
();
}
echo
'ERROR <script type="text/javascript">ok( true, "name.php executed" );</script>'
;
?>
\ No newline at end of file
test/data/params_html.php
View file @
ef819c91
<div
id=
"post"
>
<?php
foreach
(
$_POST
as
$key
=>
$value
)
echo
"<b id='
$key
'>
$value
</b>"
;
?>
</div>
<div
id=
"get"
>
<?php
foreach
(
$_GET
as
$key
=>
$value
)
echo
"<b id='
$key
'>
$value
</b>"
;
?>
<div
id=
"post"
>
<?php
foreach
(
$_POST
as
$key
=>
$value
)
echo
"<b id='
$key
'>
$value
</b>"
;
?>
</div>
<div
id=
"get"
>
<?php
foreach
(
$_GET
as
$key
=>
$value
)
echo
"<b id='
$key
'>
$value
</b>"
;
?>
</div>
\ No newline at end of file
test/data/test.js
View file @
ef819c91
var
foobar
=
"bar"
;
jQuery
(
'#ap'
).
html
(
'bar'
);
ok
(
true
,
"test.js executed"
);
var
foobar
=
"bar"
;
jQuery
(
'#ap'
).
html
(
'bar'
);
ok
(
true
,
"test.js executed"
);
test/polluted.php
View file @
ef819c91
<?php
if
(
count
(
$_POST
)
){
// second call
$includes
=
array
();
foreach
(
$_POST
as
$lib
=>
$ver
){
if
(
!
$ver
)
continue
;
$include
=
"<script type='text/javascript' src='otherlibs/
$lib
/
$ver
/
$lib
.js'></script>
\n
"
;
if
(
$lib
==
'prototype'
)
// prototype must be included first
array_unshift
(
$includes
,
$include
);
else
array_push
(
$includes
,
$include
);
}
$includes
=
implode
(
"
\n
"
,
$includes
);
$suite
=
file_get_contents
(
'index.html'
);
echo
str_replace
(
'<!-- Includes -->'
,
$includes
,
$suite
);
exit
;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xml:lang=
"en"
lang=
"en"
dir=
"ltr"
id=
"html"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
jQuery Test Suite
</title>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"qunit/testsuite.css"
/>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"data/otherlibs.css"
/>
<style
type=
"text/css"
>
form
.otherlibs
{
margin
:
20px
0
0
30px
;
}
form
.otherlibs
label
{
display
:
block
;
margin
:
5px
0
5px
30px
;
}
form
.otherlibs
input
.submit
{
margin
:
30px
0
0
0
;
}
</style>
</head>
<body
id=
"body"
>
<h1
id=
"header"
>
jQuery Test Suite
</h1>
<h2
id=
"banner"
class=
"fail"
></h2>
<h2
id=
"userAgent"
>
Choose other libraries to include
</h2>
<form
class=
"otherlibs"
action=
""
method=
"post"
>
<?php
$libs
=
scandir
(
'otherlibs'
);
foreach
(
$libs
as
$lib
){
if
(
$lib
[
0
]
==
'.'
)
continue
;
echo
"<h3>
$lib
</h3>"
;
$vers
=
scandir
(
"otherlibs/
$lib
"
);
foreach
(
$vers
as
$ver
){
if
(
$ver
[
0
]
!=
'.'
)
echo
"<label><input type='checkbox' name='
$lib
' value='
$ver
'>
$ver
</label>"
;
}
}
?>
<input
type=
"submit"
value=
"Run"
class=
"submit"
/>
</form>
</body>
</html>
<?php
if
(
count
(
$_POST
)
){
// second call
$includes
=
array
();
foreach
(
$_POST
as
$lib
=>
$ver
){
if
(
!
$ver
)
continue
;
$include
=
"<script type='text/javascript' src='otherlibs/
$lib
/
$ver
/
$lib
.js'></script>
\n
"
;
if
(
$lib
==
'prototype'
)
// prototype must be included first
array_unshift
(
$includes
,
$include
);
else
array_push
(
$includes
,
$include
);
}
$includes
=
implode
(
"
\n
"
,
$includes
);
$suite
=
file_get_contents
(
'index.html'
);
echo
str_replace
(
'<!-- Includes -->'
,
$includes
,
$suite
);
exit
;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xml:lang=
"en"
lang=
"en"
dir=
"ltr"
id=
"html"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
jQuery Test Suite
</title>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"qunit/testsuite.css"
/>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"data/otherlibs.css"
/>
<style
type=
"text/css"
>
form
.otherlibs
{
margin
:
20px
0
0
30px
;
}
form
.otherlibs
label
{
display
:
block
;
margin
:
5px
0
5px
30px
;
}
form
.otherlibs
input
.submit
{
margin
:
30px
0
0
0
;
}
</style>
</head>
<body
id=
"body"
>
<h1
id=
"header"
>
jQuery Test Suite
</h1>
<h2
id=
"banner"
class=
"fail"
></h2>
<h2
id=
"userAgent"
>
Choose other libraries to include
</h2>
<form
class=
"otherlibs"
action=
""
method=
"post"
>
<?php
$libs
=
scandir
(
'otherlibs'
);
foreach
(
$libs
as
$lib
){
if
(
$lib
[
0
]
==
'.'
)
continue
;
echo
"<h3>
$lib
</h3>"
;
$vers
=
scandir
(
"otherlibs/
$lib
"
);
foreach
(
$vers
as
$ver
){
if
(
$ver
[
0
]
!=
'.'
)
echo
"<label><input type='checkbox' name='
$lib
' value='
$ver
'>
$ver
</label>"
;
}
}
?>
<input
type=
"submit"
value=
"Run"
class=
"submit"
/>
</form>
</body>
</html>
test/unit/data.js
View file @
ef819c91
This diff is collapsed.
Click to expand it.
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