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
c470db69
Commit
c470db69
authored
Apr 07, 2011
by
Dave Methvin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jquery/jquery
parents
14193e44
6832595c
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
535 additions
and
319 deletions
+535
-319
core.js
src/core.js
+10
-17
deferred.js
src/deferred.js
+30
-2
effects.js
src/effects.js
+14
-3
queue.js
src/queue.js
+44
-1
support.js
src/support.js
+142
-152
core.js
test/unit/core.js
+20
-0
deferred.js
test/unit/deferred.js
+252
-126
effects.js
test/unit/effects.js
+23
-18
No files found.
src/core.js
View file @
c470db69
...
@@ -565,24 +565,17 @@ jQuery.extend({
...
@@ -565,24 +565,17 @@ jQuery.extend({
noop
:
function
()
{},
noop
:
function
()
{},
// Evalulates a script in a global context
// Evaluates a script in a global context
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
globalEval
:
function
(
data
)
{
globalEval
:
function
(
data
)
{
if
(
data
&&
rnotwhite
.
test
(
data
)
)
{
if
(
data
&&
rnotwhite
.
test
(
data
)
)
{
// Inspired by code by Andrea Giammarchi
// We use execScript on Internet Explorer
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
// We use an anonymous function so that context is window
var
head
=
document
.
head
||
document
.
getElementsByTagName
(
"head"
)[
0
]
||
document
.
documentElement
,
// rather than jQuery in Firefox
script
=
document
.
createElement
(
"script"
);
(
window
.
execScript
||
function
(
data
)
{
window
[
"eval"
].
call
(
window
,
data
);
if
(
jQuery
.
support
.
scriptEval
()
)
{
}
)(
data
);
script
.
appendChild
(
document
.
createTextNode
(
data
)
);
}
else
{
script
.
text
=
data
;
}
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
// This arises when a base node is used (#2709).
head
.
insertBefore
(
script
,
head
.
firstChild
);
head
.
removeChild
(
script
);
}
}
},
},
...
...
src/deferred.js
View file @
c470db69
(
function
(
jQuery
)
{
(
function
(
jQuery
)
{
var
// Promise methods
var
// Promise methods
promiseMethods
=
"
then done fail isResolved isRejected promise
"
.
split
(
" "
),
promiseMethods
=
"
done fail isResolved isRejected promise then always chain
"
.
split
(
" "
),
// Static reference to slice
// Static reference to slice
sliceDeferred
=
[].
slice
;
sliceDeferred
=
[].
slice
;
...
@@ -100,10 +100,38 @@ jQuery.extend({
...
@@ -100,10 +100,38 @@ jQuery.extend({
deferred
.
done
(
doneCallbacks
).
fail
(
failCallbacks
);
deferred
.
done
(
doneCallbacks
).
fail
(
failCallbacks
);
return
this
;
return
this
;
},
},
always
:
function
()
{
return
deferred
.
done
.
apply
(
deferred
,
arguments
).
fail
.
apply
(
this
,
arguments
);
},
fail
:
failDeferred
.
done
,
fail
:
failDeferred
.
done
,
rejectWith
:
failDeferred
.
resolveWith
,
rejectWith
:
failDeferred
.
resolveWith
,
reject
:
failDeferred
.
resolve
,
reject
:
failDeferred
.
resolve
,
isRejected
:
failDeferred
.
isResolved
,
isRejected
:
failDeferred
.
isResolved
,
// Chain
chain
:
function
(
fnDone
,
fnFail
)
{
return
jQuery
.
Deferred
(
function
(
newDefer
)
{
jQuery
.
each
(
{
done
:
[
fnDone
,
"resolve"
],
fail
:
[
fnFail
,
"reject"
]
},
function
(
handler
,
data
)
{
var
fn
=
data
[
0
],
action
=
data
[
1
],
returned
;
if
(
jQuery
.
isFunction
(
fn
)
)
{
deferred
[
handler
](
function
()
{
returned
=
fn
.
apply
(
this
,
arguments
);
if
(
jQuery
.
isFunction
(
returned
.
promise
)
)
{
returned
.
promise
().
then
(
newDefer
.
resolve
,
newDefer
.
reject
);
}
else
{
newDefer
[
action
](
returned
);
}
});
}
else
{
deferred
[
handler
](
newDefer
[
action
]
);
}
}
);
}).
promise
();
},
// Get a promise for this deferred
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
// If obj is provided, the promise aspect is added to the object
promise
:
function
(
obj
)
{
promise
:
function
(
obj
)
{
...
...
src/effects.js
View file @
c470db69
...
@@ -11,7 +11,17 @@ var elemdisplay = {},
...
@@ -11,7 +11,17 @@ var elemdisplay = {},
[
"width"
,
"marginLeft"
,
"marginRight"
,
"paddingLeft"
,
"paddingRight"
],
[
"width"
,
"marginLeft"
,
"marginRight"
,
"paddingLeft"
,
"paddingRight"
],
// opacity animations
// opacity animations
[
"opacity"
]
[
"opacity"
]
];
],
fxNow
;
function
clearFxNow
()
{
fxNow
=
undefined
;
}
function
createFxNow
()
{
setTimeout
(
clearFxNow
,
0
);
return
(
fxNow
=
jQuery
.
now
()
);
}
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
show
:
function
(
speed
,
easing
,
callback
)
{
show
:
function
(
speed
,
easing
,
callback
)
{
...
@@ -349,7 +359,7 @@ jQuery.fx.prototype = {
...
@@ -349,7 +359,7 @@ jQuery.fx.prototype = {
var
self
=
this
,
var
self
=
this
,
fx
=
jQuery
.
fx
;
fx
=
jQuery
.
fx
;
this
.
startTime
=
jQuery
.
n
ow
();
this
.
startTime
=
fxNow
||
createFxN
ow
();
this
.
start
=
from
;
this
.
start
=
from
;
this
.
end
=
to
;
this
.
end
=
to
;
this
.
unit
=
unit
||
this
.
unit
||
(
jQuery
.
cssNumber
[
this
.
prop
]
?
""
:
"px"
);
this
.
unit
=
unit
||
this
.
unit
||
(
jQuery
.
cssNumber
[
this
.
prop
]
?
""
:
"px"
);
...
@@ -394,7 +404,8 @@ jQuery.fx.prototype = {
...
@@ -394,7 +404,8 @@ jQuery.fx.prototype = {
// Each step of an animation
// Each step of an animation
step
:
function
(
gotoEnd
)
{
step
:
function
(
gotoEnd
)
{
var
t
=
jQuery
.
now
(),
done
=
true
;
var
t
=
fxNow
||
createFxNow
(),
done
=
true
;
if
(
gotoEnd
||
t
>=
this
.
options
.
duration
+
this
.
startTime
)
{
if
(
gotoEnd
||
t
>=
this
.
options
.
duration
+
this
.
startTime
)
{
this
.
now
=
this
.
end
;
this
.
now
=
this
.
end
;
...
...
src/queue.js
View file @
c470db69
...
@@ -28,7 +28,8 @@ jQuery.extend({
...
@@ -28,7 +28,8 @@ jQuery.extend({
type
=
type
||
"fx"
;
type
=
type
||
"fx"
;
var
queue
=
jQuery
.
queue
(
elem
,
type
),
var
queue
=
jQuery
.
queue
(
elem
,
type
),
fn
=
queue
.
shift
();
fn
=
queue
.
shift
(),
defer
;
// If the fx queue is dequeued, always remove the progress sentinel
// If the fx queue is dequeued, always remove the progress sentinel
if
(
fn
===
"inprogress"
)
{
if
(
fn
===
"inprogress"
)
{
...
@@ -49,6 +50,17 @@ jQuery.extend({
...
@@ -49,6 +50,17 @@ jQuery.extend({
if
(
!
queue
.
length
)
{
if
(
!
queue
.
length
)
{
jQuery
.
removeData
(
elem
,
type
+
"queue"
,
true
);
jQuery
.
removeData
(
elem
,
type
+
"queue"
,
true
);
// Look if we have observers and resolve if needed
if
((
defer
=
jQuery
.
data
(
elem
,
type
+
"defer"
,
undefined
,
true
)
))
{
// Give room for hard-coded callbacks to fire first
// and eventually add another animation on the element
setTimeout
(
function
()
{
if
(
!
jQuery
.
data
(
elem
,
type
+
"queue"
,
undefined
,
true
)
)
{
jQuery
.
removeData
(
elem
,
type
+
"defer"
,
true
);
defer
.
resolve
();
}
},
0
);
}
}
}
}
}
});
});
...
@@ -93,6 +105,37 @@ jQuery.fn.extend({
...
@@ -93,6 +105,37 @@ jQuery.fn.extend({
clearQueue
:
function
(
type
)
{
clearQueue
:
function
(
type
)
{
return
this
.
queue
(
type
||
"fx"
,
[]
);
return
this
.
queue
(
type
||
"fx"
,
[]
);
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise
:
function
(
type
,
object
)
{
if
(
typeof
type
!==
"string"
)
{
object
=
type
;
type
=
undefined
;
}
type
=
type
||
"fx"
;
var
defer
=
jQuery
.
Deferred
(),
elements
=
this
,
i
=
elements
.
length
,
count
=
1
,
deferDataKey
=
type
+
"defer"
,
queueDataKey
=
type
+
"queue"
;
function
resolve
()
{
if
(
!
(
--
count
)
)
{
defer
.
resolveWith
(
elements
,
[
elements
]
);
}
}
while
(
i
--
)
{
if
((
tmp
=
jQuery
.
data
(
elements
[
i
],
deferDataKey
,
undefined
,
true
)
||
jQuery
.
data
(
elements
[
i
],
queueDataKey
,
undefined
,
true
)
&&
jQuery
.
data
(
elements
[
i
],
deferDataKey
,
jQuery
.
_Deferred
(),
true
)
))
{
count
++
;
tmp
.
done
(
resolve
);
}
}
resolve
();
return
defer
.
promise
();
}
}
});
});
...
...
src/support.js
View file @
c470db69
(
function
(
jQuery
)
{
(
function
(
jQuery
)
{
(
function
()
{
jQuery
.
support
=
(
function
()
{
jQuery
.
support
=
{};
var
div
=
document
.
createElement
(
"div"
),
all
,
var
div
=
document
.
createElement
(
"div"
);
a
,
select
,
div
.
style
.
display
=
"none"
;
opt
,
input
,
support
,
fragment
,
body
,
bodyStyle
,
tds
,
events
,
eventName
,
i
,
isSupported
;
// Preliminary tests
div
.
innerHTML
=
" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"
;
div
.
innerHTML
=
" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"
;
var
all
=
div
.
getElementsByTagName
(
"*"
),
all
=
div
.
getElementsByTagName
(
"*"
);
a
=
div
.
getElementsByTagName
(
"a"
)[
0
],
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
select
=
document
.
createElement
(
"select"
),
opt
=
select
.
appendChild
(
document
.
createElement
(
"option"
)
),
input
=
div
.
getElementsByTagName
(
"input"
)[
0
];
// Can't get basic test support
// Can't get basic test support
if
(
!
all
||
!
all
.
length
||
!
a
)
{
if
(
!
all
||
!
all
.
length
||
!
a
)
{
return
;
return
{}
;
}
}
jQuery
.
support
=
{
// First batch of supports tests
select
=
document
.
createElement
(
"select"
);
opt
=
select
.
appendChild
(
document
.
createElement
(
"option"
)
);
input
=
div
.
getElementsByTagName
(
"input"
)[
0
];
support
=
{
// IE strips leading whitespace when .innerHTML is used
// IE strips leading whitespace when .innerHTML is used
leadingWhitespace
:
div
.
firstChild
.
nodeType
===
3
,
leadingWhitespace
:
(
div
.
firstChild
.
nodeType
===
3
)
,
// Make sure that tbody elements aren't automatically inserted
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
// IE will insert them into empty tables
tbody
:
!
div
.
getElementsByTagName
(
"tbody"
).
length
,
tbody
:
!
div
.
getElementsByTagName
(
"tbody"
).
length
,
// Make sure that link elements get serialized correctly by innerHTML
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
// This requires a wrapper element in IE
htmlSerialize
:
!!
div
.
getElementsByTagName
(
"link"
).
length
,
htmlSerialize
:
!!
div
.
getElementsByTagName
(
"link"
).
length
,
// Get the style information from getAttribute
// Get the style information from getAttribute
// (IE uses .cssText insted)
// (IE uses .cssText inste
a
d)
style
:
/red/
.
test
(
a
.
getAttribute
(
"style"
)
),
style
:
/red/
.
test
(
a
.
getAttribute
(
"style"
)
),
// Make sure that URLs aren't manipulated
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
// (IE normalizes it by default)
hrefNormalized
:
a
.
getAttribute
(
"href"
)
===
"/a"
,
hrefNormalized
:
(
a
.
getAttribute
(
"href"
)
===
"/a"
)
,
// Make sure that element opacity exists
// Make sure that element opacity exists
// (IE uses filter instead)
// (IE uses filter instead)
...
@@ -59,97 +73,71 @@
...
@@ -59,97 +73,71 @@
optSelected
:
opt
.
selected
,
optSelected
:
opt
.
selected
,
// Will be defined later
// Will be defined later
submitBubbles
:
true
,
changeBubbles
:
true
,
deleteExpando
:
true
,
deleteExpando
:
true
,
optDisabled
:
false
,
checkClone
:
false
,
noCloneEvent
:
true
,
noCloneEvent
:
true
,
noCloneChecked
:
true
,
boxModel
:
null
,
inlineBlockNeedsLayout
:
false
,
inlineBlockNeedsLayout
:
false
,
shrinkWrapBlocks
:
false
,
shrinkWrapBlocks
:
false
,
reliableHiddenOffsets
:
true
,
reliableMarginRight
:
true
reliableMarginRight
:
true
};
};
// Make sure checked status is properly cloned
input
.
checked
=
true
;
input
.
checked
=
true
;
jQuery
.
support
.
noCloneChecked
=
input
.
cloneNode
(
true
).
checked
;
support
.
noCloneChecked
=
input
.
cloneNode
(
true
).
checked
;
// Make sure that the options inside disabled selects aren't marked as disabled
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as diabled)
// (WebKit marks them as di
s
abled)
select
.
disabled
=
true
;
select
.
disabled
=
true
;
jQuery
.
support
.
optDisabled
=
!
opt
.
disabled
;
support
.
optDisabled
=
!
opt
.
disabled
;
var
_scriptEval
=
null
;
jQuery
.
support
.
scriptEval
=
function
()
{
if
(
_scriptEval
===
null
)
{
var
root
=
document
.
documentElement
,
script
=
document
.
createElement
(
"script"
),
id
=
"script"
+
jQuery
.
now
();
// Make sure that the execution of code works by injecting a script
// tag with appendChild/createTextNode
// (IE doesn't support this, fails, and uses .text instead)
try
{
script
.
appendChild
(
document
.
createTextNode
(
"window."
+
id
+
"=1;"
)
);
}
catch
(
e
)
{}
root
.
insertBefore
(
script
,
root
.
firstChild
);
if
(
window
[
id
]
)
{
_scriptEval
=
true
;
delete
window
[
id
];
}
else
{
_scriptEval
=
false
;
}
root
.
removeChild
(
script
);
}
return
_scriptEval
;
};
// Test to see if it's possible to delete an expando from an element
// Test to see if it's possible to delete an expando from an element
// Fails in Internet Explorer
// Fails in Internet Explorer
try
{
try
{
delete
div
.
test
;
delete
div
.
test
;
}
catch
(
e
)
{
}
catch
(
e
)
{
support
.
deleteExpando
=
false
;
jQuery
.
support
.
deleteExpando
=
false
;
}
}
if
(
!
div
.
addEventListener
&&
div
.
attachEvent
&&
div
.
fireEvent
)
{
if
(
!
div
.
addEventListener
&&
div
.
attachEvent
&&
div
.
fireEvent
)
{
div
.
attachEvent
(
"onclick"
,
function
click
()
{
div
.
attachEvent
(
"onclick"
,
function
click
()
{
// Cloning a node shouldn't copy over any
// Cloning a node shouldn't copy over any
// bound event handlers (IE does this)
// bound event handlers (IE does this)
jQuery
.
support
.
noCloneEvent
=
false
;
support
.
noCloneEvent
=
false
;
div
.
detachEvent
(
"onclick"
,
click
);
div
.
detachEvent
(
"onclick"
,
click
);
});
}
);
div
.
cloneNode
(
true
).
fireEvent
(
"onclick"
);
div
.
cloneNode
(
true
).
fireEvent
(
"onclick"
);
}
}
div
=
document
.
createElement
(
"div"
);
div
.
innerHTML
=
"<input type='radio' name='radiotest' checked='checked'/>"
;
div
.
innerHTML
=
"<input type='radio' name='radiotest' checked='checked'/>"
;
var
fragment
=
document
.
createDocumentFragment
();
fragment
=
document
.
createDocumentFragment
();
fragment
.
appendChild
(
div
.
firstChild
);
fragment
.
appendChild
(
div
.
firstChild
);
// WebKit doesn't clone checked state correctly in fragments
// WebKit doesn't clone checked state correctly in fragments
jQuery
.
support
.
checkClone
=
fragment
.
cloneNode
(
true
).
cloneNode
(
true
).
lastChild
.
checked
;
support
.
checkClone
=
fragment
.
cloneNode
(
true
).
cloneNode
(
true
).
lastChild
.
checked
;
// Figure out if the W3C box model works as expected
div
.
innerHTML
=
""
;
// document.body must exist before we can do this
jQuery
(
function
()
{
var
div
=
document
.
createElement
(
"div"
),
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
// Frameset documents with no body should not run this code
if
(
!
body
)
{
return
;
}
// Figure out if the W3C box model works as expected
div
.
style
.
width
=
div
.
style
.
paddingLeft
=
"1px"
;
div
.
style
.
width
=
div
.
style
.
paddingLeft
=
"1px"
;
// We use our own, invisible, body
body
=
document
.
createElement
(
"body"
);
bodyStyle
=
{
visibility
:
"hidden"
,
width
:
0
,
height
:
0
,
border
:
0
,
margin
:
0
};
for
(
i
in
bodyStyle
)
{
body
.
style
[
i
]
=
bodyStyle
[
i
];
}
body
.
appendChild
(
div
);
body
.
appendChild
(
div
);
jQuery
.
boxModel
=
jQuery
.
support
.
boxModel
=
div
.
offsetWidth
===
2
;
document
.
documentElement
.
appendChild
(
body
);
support
.
boxModel
=
div
.
offsetWidth
===
2
;
if
(
"zoom"
in
div
.
style
)
{
if
(
"zoom"
in
div
.
style
)
{
// Check if natively block-level elements act like inline-block
// Check if natively block-level elements act like inline-block
...
@@ -158,17 +146,17 @@
...
@@ -158,17 +146,17 @@
// (IE < 8 does this)
// (IE < 8 does this)
div
.
style
.
display
=
"inline"
;
div
.
style
.
display
=
"inline"
;
div
.
style
.
zoom
=
1
;
div
.
style
.
zoom
=
1
;
jQuery
.
support
.
inlineBlockNeedsLayout
=
div
.
offsetWidth
===
2
;
support
.
inlineBlockNeedsLayout
=
(
div
.
offsetWidth
===
2
)
;
// Check if elements with layout shrink-wrap their children
// Check if elements with layout shrink-wrap their children
// (IE 6 does this)
// (IE 6 does this)
div
.
style
.
display
=
""
;
div
.
style
.
display
=
""
;
div
.
innerHTML
=
"<div style='width:4px;'></div>"
;
div
.
innerHTML
=
"<div style='width:4px;'></div>"
;
jQuery
.
support
.
shrinkWrapBlocks
=
div
.
offsetWidth
!==
2
;
support
.
shrinkWrapBlocks
=
(
div
.
offsetWidth
!==
2
)
;
}
}
div
.
innerHTML
=
"<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"
;
div
.
innerHTML
=
"<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"
;
var
tds
=
div
.
getElementsByTagName
(
"td"
);
tds
=
div
.
getElementsByTagName
(
"td"
);
// Check if table cells still have offsetWidth/Height when they are set
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// to display:none and there are still other visible table cells in a
...
@@ -177,14 +165,14 @@
...
@@ -177,14 +165,14 @@
// display:none (it is still safe to use offsets if a parent element is
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
// hidden; don safety goggles and see bug #4512 for more information).
// (only IE 8 fails this test)
// (only IE 8 fails this test)
jQuery
.
support
.
reliableHiddenOffsets
=
tds
[
0
].
offsetHeight
===
0
;
isSupported
=
(
tds
[
0
].
offsetHeight
===
0
)
;
tds
[
0
].
style
.
display
=
""
;
tds
[
0
].
style
.
display
=
""
;
tds
[
1
].
style
.
display
=
"none"
;
tds
[
1
].
style
.
display
=
"none"
;
// Check if empty table cells still have offsetWidth/Height
// Check if empty table cells still have offsetWidth/Height
// (IE < 8 fail this test)
// (IE < 8 fail this test)
jQuery
.
support
.
reliableHiddenOffsets
=
jQuery
.
support
.
reliableHiddenOffsets
&&
tds
[
0
].
offsetHeight
===
0
;
support
.
reliableHiddenOffsets
=
isSupported
&&
(
tds
[
0
].
offsetHeight
===
0
)
;
div
.
innerHTML
=
""
;
div
.
innerHTML
=
""
;
// Check if div with explicit width and no margin-right incorrectly
// Check if div with explicit width and no margin-right incorrectly
...
@@ -195,40 +183,42 @@
...
@@ -195,40 +183,42 @@
if
(
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
)
{
if
(
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
)
{
div
.
style
.
width
=
"1px"
;
div
.
style
.
width
=
"1px"
;
div
.
style
.
marginRight
=
"0"
;
div
.
style
.
marginRight
=
"0"
;
jQuery
.
support
.
reliableMarginRight
=
(
parseInt
(
document
.
defaultView
.
getComputedStyle
(
div
,
null
).
marginRight
,
10
)
||
0
)
===
0
;
support
.
reliableMarginRight
=
(
parseInt
(
document
.
defaultView
.
getComputedStyle
(
div
).
marginRight
,
10
)
||
0
)
===
0
;
}
}
body
.
removeChild
(
div
).
style
.
display
=
"none"
;
// Remove the body element we added
div
=
tds
=
null
;
document
.
documentElement
.
removeChild
(
body
);
});
// Technique from Juriy Zaytsev
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
var
eventSupported
=
function
(
eventName
)
{
var
el
=
document
.
createElement
(
"div"
);
eventName
=
"on"
+
eventName
;
// We only care about the case where non-standard event systems
// We only care about the case where non-standard event systems
// are used, namely in IE. Short-circuiting here helps us to
// are used, namely in IE. Short-circuiting here helps us to
// avoid an eval call (in setAttribute) which can cause CSP
// avoid an eval call (in setAttribute) which can cause CSP
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
if
(
!
el
.
attachEvent
)
{
if
(
div
.
attachEvent
)
{
return
true
;
for
(
i
in
{
}
submit
:
1
,
change
:
1
,
var
isSupported
=
(
eventName
in
el
);
focusin
:
1
}
)
{
eventName
=
"on"
+
i
;
isSupported
=
(
eventName
in
div
);
if
(
!
isSupported
)
{
if
(
!
isSupported
)
{
el
.
setAttribute
(
eventName
,
"return;"
);
div
.
setAttribute
(
eventName
,
"return;"
);
isSupported
=
typeof
el
[
eventName
]
===
"function"
;
isSupported
=
(
typeof
div
[
eventName
]
===
"function"
);
}
support
[
i
+
"Bubbles"
]
=
isSupported
;
}
}
}
return
isSupported
;
};
jQuery
.
support
.
submitBubbles
=
eventSupported
(
"submit"
);
jQuery
.
support
.
changeBubbles
=
eventSupported
(
"change"
);
jQuery
.
support
.
focusinBubbles
=
document
.
attachEvent
&&
eventSupported
(
"focusin"
);
// release memory in IE
// release memory in IE
div
=
all
=
a
=
null
;
body
=
div
=
all
=
a
=
tds
=
undefined
;
return
support
;
})();
})();
// Keep track of boxModel
jQuery
.
boxModel
=
jQuery
.
support
.
boxModel
;
})(
jQuery
);
})(
jQuery
);
test/unit/core.js
View file @
c470db69
...
@@ -172,6 +172,26 @@ test("selector state", function() {
...
@@ -172,6 +172,26 @@ test("selector state", function() {
);
);
});
});
test
(
"globalEval"
,
function
()
{
expect
(
3
);
jQuery
.
globalEval
(
"var globalEvalTest = true;"
);
ok
(
window
.
globalEvalTest
,
"Test variable declarations are global"
);
window
.
globalEvalTest
=
false
;
jQuery
.
globalEval
(
"globalEvalTest = true;"
);
ok
(
window
.
globalEvalTest
,
"Test variable assignments are global"
);
window
.
globalEvalTest
=
false
;
jQuery
.
globalEval
(
"this.globalEvalTest = true;"
);
ok
(
window
.
globalEvalTest
,
"Test context (this) is the window object"
);
window
.
globalEvalTest
=
undefined
;
});
if
(
!
isLocal
)
{
if
(
!
isLocal
)
{
test
(
"browser"
,
function
()
{
test
(
"browser"
,
function
()
{
stop
();
stop
();
...
...
test/unit/deferred.js
View file @
c470db69
This diff is collapsed.
Click to expand it.
test/unit/effects.js
View file @
c470db69
...
@@ -717,59 +717,64 @@ jQuery.each( {
...
@@ -717,59 +717,64 @@ jQuery.each( {
var
anim
=
{
width
:
t_w
,
height
:
t_h
,
opacity
:
t_o
};
var
anim
=
{
width
:
t_w
,
height
:
t_h
,
opacity
:
t_o
};
elem
.
animate
(
anim
,
50
,
function
(){
elem
.
animate
(
anim
,
50
);
jQuery
.
when
(
elem
).
done
(
function
(
elem
){
elem
=
elem
[
0
];
if
(
t_w
==
"show"
)
if
(
t_w
==
"show"
)
equals
(
this
.
style
.
display
,
"block"
,
"Showing, display should block: "
+
this
.
style
.
display
);
equals
(
elem
.
style
.
display
,
"block"
,
"Showing, display should block: "
+
elem
.
style
.
display
);
if
(
t_w
==
"hide"
||
t_w
==
"show"
)
if
(
t_w
==
"hide"
||
t_w
==
"show"
)
ok
(
f_w
===
""
?
this
.
style
.
width
===
f_w
:
this
.
style
.
width
.
indexOf
(
f_w
)
===
0
,
"Width must be reset to "
+
f_w
+
": "
+
this
.
style
.
width
);
ok
(
f_w
===
""
?
elem
.
style
.
width
===
f_w
:
elem
.
style
.
width
.
indexOf
(
f_w
)
===
0
,
"Width must be reset to "
+
f_w
+
": "
+
elem
.
style
.
width
);
if
(
t_h
==
"hide"
||
t_h
==
"show"
)
if
(
t_h
==
"hide"
||
t_h
==
"show"
)
ok
(
f_h
===
""
?
this
.
style
.
height
===
f_h
:
this
.
style
.
height
.
indexOf
(
f_h
)
===
0
,
"Height must be reset to "
+
f_h
+
": "
+
this
.
style
.
height
);
ok
(
f_h
===
""
?
elem
.
style
.
height
===
f_h
:
elem
.
style
.
height
.
indexOf
(
f_h
)
===
0
,
"Height must be reset to "
+
f_h
+
": "
+
elem
.
style
.
height
);
var
cur_o
=
jQuery
.
style
(
this
,
"opacity"
);
var
cur_o
=
jQuery
.
style
(
elem
,
"opacity"
);
if
(
t_o
==
"hide"
||
t_o
==
"show"
)
if
(
t_o
==
"hide"
||
t_o
==
"show"
)
equals
(
cur_o
,
f_o
,
"Opacity must be reset to "
+
f_o
+
": "
+
cur_o
);
equals
(
cur_o
,
f_o
,
"Opacity must be reset to "
+
f_o
+
": "
+
cur_o
);
if
(
t_w
==
"hide"
)
if
(
t_w
==
"hide"
)
equals
(
this
.
style
.
display
,
"none"
,
"Hiding, display should be none: "
+
this
.
style
.
display
);
equals
(
elem
.
style
.
display
,
"none"
,
"Hiding, display should be none: "
+
elem
.
style
.
display
);
if
(
t_o
.
constructor
==
Number
)
{
if
(
t_o
.
constructor
==
Number
)
{
equals
(
cur_o
,
t_o
,
"Final opacity should be "
+
t_o
+
": "
+
cur_o
);
equals
(
cur_o
,
t_o
,
"Final opacity should be "
+
t_o
+
": "
+
cur_o
);
ok
(
jQuery
.
css
(
this
,
"opacity"
)
!=
""
||
cur_o
==
t_o
,
"Opacity should be explicitly set to "
+
t_o
+
", is instead: "
+
cur_o
);
ok
(
jQuery
.
css
(
elem
,
"opacity"
)
!=
""
||
cur_o
==
t_o
,
"Opacity should be explicitly set to "
+
t_o
+
", is instead: "
+
cur_o
);
}
}
if
(
t_w
.
constructor
==
Number
)
{
if
(
t_w
.
constructor
==
Number
)
{
equals
(
this
.
style
.
width
,
t_w
+
"px"
,
"Final width should be "
+
t_w
+
": "
+
this
.
style
.
width
);
equals
(
elem
.
style
.
width
,
t_w
+
"px"
,
"Final width should be "
+
t_w
+
": "
+
elem
.
style
.
width
);
var
cur_w
=
jQuery
.
css
(
this
,
"width"
);
var
cur_w
=
jQuery
.
css
(
elem
,
"width"
);
ok
(
this
.
style
.
width
!=
""
||
cur_w
==
t_w
,
"Width should be explicitly set to "
+
t_w
+
", is instead: "
+
cur_w
);
ok
(
elem
.
style
.
width
!=
""
||
cur_w
==
t_w
,
"Width should be explicitly set to "
+
t_w
+
", is instead: "
+
cur_w
);
}
}
if
(
t_h
.
constructor
==
Number
)
{
if
(
t_h
.
constructor
==
Number
)
{
equals
(
this
.
style
.
height
,
t_h
+
"px"
,
"Final height should be "
+
t_h
+
": "
+
this
.
style
.
height
);
equals
(
elem
.
style
.
height
,
t_h
+
"px"
,
"Final height should be "
+
t_h
+
": "
+
elem
.
style
.
height
);
var
cur_h
=
jQuery
.
css
(
this
,
"height"
);
var
cur_h
=
jQuery
.
css
(
elem
,
"height"
);
ok
(
this
.
style
.
height
!=
""
||
cur_h
==
t_h
,
"Height should be explicitly set to "
+
t_h
+
", is instead: "
+
cur_w
);
ok
(
elem
.
style
.
height
!=
""
||
cur_h
==
t_h
,
"Height should be explicitly set to "
+
t_h
+
", is instead: "
+
cur_w
);
}
}
if
(
t_h
==
"show"
)
{
if
(
t_h
==
"show"
)
{
var
old_h
=
jQuery
.
css
(
this
,
"height"
);
var
old_h
=
jQuery
.
css
(
elem
,
"height"
);
jQuery
(
this
).
append
(
"<br/>Some more text<br/>and some more..."
);
jQuery
(
elem
).
append
(
"<br/>Some more text<br/>and some more..."
);
if
(
/Auto/
.
test
(
fn
)
)
{
if
(
/Auto/
.
test
(
fn
)
)
{
notEqual
(
jQuery
.
css
(
this
,
"height"
),
old_h
,
"Make sure height is auto."
);
notEqual
(
jQuery
.
css
(
elem
,
"height"
),
old_h
,
"Make sure height is auto."
);
}
else
{
}
else
{
equals
(
jQuery
.
css
(
this
,
"height"
),
old_h
,
"Make sure height is not auto."
);
equals
(
jQuery
.
css
(
elem
,
"height"
),
old_h
,
"Make sure height is not auto."
);
}
}
}
}
// manually remove generated element
// manually remove generated element
jQuery
(
this
).
remove
();
jQuery
(
elem
).
remove
();
start
();
start
();
});
});
...
...
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