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
ecd10464
Commit
ecd10464
authored
Sep 08, 2011
by
Dave Methvin
Committed by
timmywil
Sep 19, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #9951. Precompute path for `.trigger()` to match up with W3C spec.
parent
0ccb88d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
33 deletions
+36
-33
event.js
src/event.js
+36
-33
No files found.
src/event.js
View file @
ecd10464
...
@@ -273,7 +273,17 @@ jQuery.event = {
...
@@ -273,7 +273,17 @@ jQuery.event = {
// Event object or event type
// Event object or event type
var
type
=
event
.
type
||
event
,
var
type
=
event
.
type
||
event
,
namespaces
=
[],
namespaces
=
[],
exclusive
,
origType
,
cur
,
ontype
,
handle
,
old
,
special
;
exclusive
,
i
,
cur
,
old
,
ontype
,
special
,
doc
,
eventPath
,
bubbleType
,
addHandlers
=
function
(
elem
,
type
)
{
// Defer getting handler in case propagation is stopped
if
(
(
jQuery
.
_data
(
elem
,
"events"
)
||
{})[
type
]
)
{
eventPath
.
push
({
elem
:
elem
,
type
:
type
/*, handler: jQuery._data( elem, "handle" ) */
});
}
// IE doesn't like method names with a colon (#3533, #8272)
if
(
ontype
&&
jQuery
.
acceptData
(
elem
)
&&
elem
[
ontype
]
)
{
eventPath
.
push
({
elem
:
elem
,
type
:
type
,
handler
:
elem
[
ontype
]
});
}
};
if
(
type
.
indexOf
(
"!"
)
>=
0
)
{
if
(
type
.
indexOf
(
"!"
)
>=
0
)
{
// Exclusive events trigger only for the exact event (no namespaces)
// Exclusive events trigger only for the exact event (no namespaces)
...
@@ -306,6 +316,7 @@ jQuery.event = {
...
@@ -306,6 +316,7 @@ jQuery.event = {
event
.
exclusive
=
exclusive
;
event
.
exclusive
=
exclusive
;
event
.
namespace
=
namespaces
.
join
(
"."
);
event
.
namespace
=
namespaces
.
join
(
"."
);
event
.
namespace_re
=
event
.
namespace
?
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
join
(
"
\\
.(?:.*
\\
.)?"
)
+
"(
\\
.|$)"
)
:
null
;
event
.
namespace_re
=
event
.
namespace
?
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
join
(
"
\\
.(?:.*
\\
.)?"
)
+
"(
\\
.|$)"
)
:
null
;
ontype
=
type
.
indexOf
(
":"
)
<
0
?
"on"
+
type
:
""
;
// triggerHandler() and global events don't bubble or run the default action
// triggerHandler() and global events don't bubble or run the default action
if
(
onlyHandlers
||
!
elem
)
{
if
(
onlyHandlers
||
!
elem
)
{
...
@@ -342,39 +353,31 @@ jQuery.event = {
...
@@ -342,39 +353,31 @@ jQuery.event = {
if
(
special
.
trigger
&&
special
.
trigger
.
apply
(
elem
,
data
)
===
false
)
{
if
(
special
.
trigger
&&
special
.
trigger
.
apply
(
elem
,
data
)
===
false
)
{
return
;
return
;
}
}
origType
=
type
;
if
(
special
.
bindType
)
{
type
=
event
.
type
=
special
.
bindType
;
}
// IE doesn't like method names with a colon (#3533, #8272)
ontype
=
type
.
indexOf
(
":"
)
<
0
?
"on"
+
type
:
""
;
// Fire event on the current element, then bubble up the DOM tree
// Determine event propagation path in advance, per W3C events spec (#9951)
cur
=
elem
;
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
do
{
// Always fire handlers for the target, even if prop is stopped in advance
handle
=
jQuery
.
_data
(
cur
,
"handle"
);
eventPath
=
[];
addHandlers
(
elem
,
special
.
bindType
||
type
);
event
.
currentTarget
=
cur
;
doc
=
elem
.
ownerDocument
;
if
(
handle
)
{
if
(
doc
&&
!
jQuery
.
isWindow
(
elem
)
&
!
event
.
isPropagationStopped
()
)
{
handle
.
apply
(
cur
,
data
);
bubbleType
=
special
.
delegateType
||
type
;
for
(
cur
=
elem
.
parentNode
;
cur
;
cur
=
cur
.
parentNode
)
{
addHandlers
(
cur
,
bubbleType
);
}
}
addHandlers
(
doc
.
defaultView
||
doc
.
parentWindow
||
window
,
bubbleType
);
// Trigger an inline bound script
if
(
ontype
&&
jQuery
.
acceptData
(
cur
)
&&
cur
[
ontype
]
&&
cur
[
ontype
].
apply
(
cur
,
data
)
===
false
)
{
event
.
result
=
false
;
event
.
preventDefault
();
}
}
// May need to change the event type when bubbling special events
// Bubble up the DOM tree
if
(
cur
===
elem
&&
special
.
delegateType
)
{
for
(
i
=
0
;
i
<
eventPath
.
length
;
i
++
)
{
event
.
type
=
special
.
delegateType
;
cur
=
eventPath
[
i
];
event
.
type
=
cur
.
type
;
(
cur
.
handler
||
jQuery
.
_data
(
cur
.
elem
,
"handle"
)).
apply
(
cur
.
elem
,
data
);
if
(
event
.
isPropagationStopped
()
)
{
break
;
}
}
}
// Bubble up to document, then to window; watch for a global parentNode or ownerDocument var (#9724)
event
.
type
=
type
;
cur
=
(
!
cur
.
setInterval
&&
cur
.
parentNode
||
cur
.
ownerDocument
)
||
cur
===
event
.
target
.
ownerDocument
&&
window
;
}
while
(
cur
&&
!
event
.
isPropagationStopped
()
);
type
=
event
.
type
=
origType
;
// If nobody prevented the default action, do it now
// If nobody prevented the default action, do it now
if
(
!
event
.
isDefaultPrevented
()
)
{
if
(
!
event
.
isDefaultPrevented
()
)
{
...
@@ -745,7 +748,7 @@ if ( !jQuery.support.submitBubbles ) {
...
@@ -745,7 +748,7 @@ if ( !jQuery.support.submitBubbles ) {
var
elem
=
e
.
target
,
var
elem
=
e
.
target
,
type
=
jQuery
.
nodeName
(
elem
,
"input"
)
||
jQuery
.
nodeName
(
elem
,
"button"
)
?
elem
.
type
:
""
;
type
=
jQuery
.
nodeName
(
elem
,
"input"
)
||
jQuery
.
nodeName
(
elem
,
"button"
)
?
elem
.
type
:
""
;
// Do the elem.form check after type to avoid VML-related crash in IE (#
TODO
)
// Do the elem.form check after type to avoid VML-related crash in IE (#
9807
)
if
(
(
e
.
type
===
"click"
&&
(
type
===
"submit"
||
type
===
"image"
)
&&
elem
.
form
)
||
if
(
(
e
.
type
===
"click"
&&
(
type
===
"submit"
||
type
===
"image"
)
&&
elem
.
form
)
||
(
e
.
type
===
"keypress"
&&
e
.
keyCode
===
13
&&
(
type
===
"text"
||
type
===
"password"
)
&&
elem
.
form
)
)
{
(
e
.
type
===
"keypress"
&&
e
.
keyCode
===
13
&&
(
type
===
"text"
||
type
===
"password"
)
&&
elem
.
form
)
)
{
simulate
(
"submit"
,
this
,
e
);
simulate
(
"submit"
,
this
,
e
);
...
...
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