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
92a80cbd
Commit
92a80cbd
authored
Sep 20, 2011
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds implementation tests for jQuery.event.propHooks #8789
parent
26898f0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
6 deletions
+65
-6
event.js
test/unit/event.js
+65
-6
No files found.
test/unit/event.js
View file @
92a80cbd
...
@@ -54,7 +54,7 @@ test("Handler changes and .trigger() order", function() {
...
@@ -54,7 +54,7 @@ test("Handler changes and .trigger() order", function() {
markup.find( "b" ).trigger( "click" );
markup.find( "b" ).trigger( "click" );
equals( path, "p div body html ", "Delivered all events" )
equals( path, "p div body html ", "Delivered all events" )
markup.remove();
markup.remove();
});
});
*/
*/
...
@@ -2332,13 +2332,13 @@ test(".on and .off", function() {
...
@@ -2332,13 +2332,13 @@ test(".on and .off", function() {
// We should have removed all the event handlers ... kinda hacky way to check this
// We should have removed all the event handlers ... kinda hacky way to check this
var
data
=
jQuery
.
data
[
jQuery
(
"#onandoff"
)[
0
].
expando
]
||
{};
var
data
=
jQuery
.
data
[
jQuery
(
"#onandoff"
)[
0
].
expando
]
||
{};
equals
(
data
.
events
,
undefined
,
"no events left"
);
equals
(
data
.
events
,
undefined
,
"no events left"
);
jQuery
(
"#onandoff"
).
remove
();
jQuery
(
"#onandoff"
).
remove
();
});
});
test
(
"delegated events quickIs"
,
function
()
{
test
(
"delegated events quickIs"
,
function
()
{
expect
(
23
);
expect
(
23
);
var
markup
=
jQuery
(
var
markup
=
jQuery
(
'<div>'
+
'<div>'
+
'<p class="D">'
+
'<p class="D">'
+
'dead<b devo="cool">beat</b>club'
+
'dead<b devo="cool">beat</b>club'
+
...
@@ -2349,12 +2349,12 @@ test("delegated events quickIs", function() {
...
@@ -2349,12 +2349,12 @@ test("delegated events quickIs", function() {
'</div>'
'</div>'
),
),
str
,
str
,
check
=
function
(
el
,
expect
){
check
=
function
(
el
,
expect
){
str
=
""
;
str
=
""
;
markup
.
find
(
el
).
trigger
(
"blink"
);
markup
.
find
(
el
).
trigger
(
"blink"
);
equals
(
str
,
expect
,
"On "
+
el
);
equals
(
str
,
expect
,
"On "
+
el
);
},
},
func
=
function
(
e
){
func
=
function
(
e
){
var
tag
=
this
.
nodeName
.
toLowerCase
();
var
tag
=
this
.
nodeName
.
toLowerCase
();
str
+=
(
str
&&
" "
)
+
tag
+
"|"
+
e
.
handleObj
.
selector
;
str
+=
(
str
&&
" "
)
+
tag
+
"|"
+
e
.
handleObj
.
selector
;
ok
(
e
.
handleObj
.
quick
,
"Selector "
+
e
.
handleObj
.
selector
+
" on "
+
tag
+
" is a quickIs case"
);
ok
(
e
.
handleObj
.
quick
,
"Selector "
+
e
.
handleObj
.
selector
+
" on "
+
tag
+
" is a quickIs case"
);
...
@@ -2379,7 +2379,7 @@ test("delegated events quickIs", function() {
...
@@ -2379,7 +2379,7 @@ test("delegated events quickIs", function() {
check
(
"p"
,
"p|.D p|:first-child"
);
check
(
"p"
,
"p|.D p|:first-child"
);
check
(
"b"
,
"b|[devo=cool] p|.D p|:first-child"
);
check
(
"b"
,
"b|[devo=cool] p|.D p|:first-child"
);
check
(
"em"
,
"em|em q|#famous em|em em|em:empty em|em:last-child q|#famous"
);
check
(
"em"
,
"em|em q|#famous em|em em|em:empty em|em:last-child q|#famous"
);
markup
.
find
(
"b"
).
attr
(
"devo"
,
"NO"
);
markup
.
find
(
"b"
).
attr
(
"devo"
,
"NO"
);
check
(
"b"
,
"b|[devo='NO'] p|.D p|:first-child"
);
check
(
"b"
,
"b|[devo='NO'] p|.D p|:first-child"
);
...
@@ -2460,6 +2460,65 @@ test("delegated events quickIs", function() {
...
@@ -2460,6 +2460,65 @@ test("delegated events quickIs", function() {
})();
})();
test
(
"jQuery.event.propHooks"
,
function
()
{
expect
(
1
);
ok
(
jQuery
.
event
.
propHooks
,
"jQuery.event.propHooks exists"
);
});
test
(
"jQuery.event.propHooks as function"
,
function
()
{
expect
(
2
);
jQuery
(
"<div id='hook-fixture'></div>"
).
appendTo
(
"#qunit-fixture"
);
var
$fixture
=
jQuery
(
"#hook-fixture"
);
// Does not exist
$fixture
.
bind
(
"click"
,
function
(
event
)
{
ok
(
!
(
"propC"
in
event
),
"event.propC Does not exist"
);
}).
trigger
(
"click"
);
$fixture
.
unbind
(
"click"
);
// Store as function
jQuery
.
event
.
propHooks
[
"custom"
]
=
function
(
event
)
{
// receives the event object for processing
event
.
propC
=
true
;
return
event
;
};
$fixture
.
bind
(
"custom"
,
function
(
event
)
{
ok
(
event
.
propC
,
"event.propC exists"
);
}).
trigger
(
"custom"
);
});
test
(
"jQuery.event.propHooks usecase"
,
function
()
{
expect
(
3
);
jQuery
(
"<div id='hook-fixture'></div>"
).
appendTo
(
"#qunit-fixture"
);
var
$fixture
=
jQuery
(
"#hook-fixture"
);
$fixture
.
bind
(
"fakedrop"
,
function
(
event
)
{
ok
(
!
(
"dataTransfer"
in
event
),
"event.dataTransfer is not available"
);
}).
trigger
(
"fakedrop"
);
$fixture
.
unbind
(
"fakedrop"
);
jQuery
.
event
.
propHooks
[
"fakedrop"
]
=
function
(
event
)
{
event
.
dataTransfer
=
"some val"
;
return
event
;
};
$fixture
.
bind
(
"fakedrop"
,
function
(
event
)
{
ok
(
(
"dataTransfer"
in
event
),
"event.dataTransfer exists, just copied"
);
equal
(
event
.
dataTransfer
,
"some val"
,
"event.dataTransfer equal 'some val'"
);
}).
trigger
(
"fakedrop"
);
$fixture
.
unbind
(
"fakedrop"
);
});
/*
/*
test("event properties", function() {
test("event properties", function() {
stop();
stop();
...
...
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