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
2f11ba7c
Commit
2f11ba7c
authored
Apr 07, 2011
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow specific custom events to exit trigger early if there are no handlers bound for that type.
parent
bbd9c776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
event.js
src/event.js
+15
-2
No files found.
src/event.js
View file @
2f11ba7c
...
@@ -276,6 +276,14 @@ jQuery.event = {
...
@@ -276,6 +276,14 @@ jQuery.event = {
}
}
}
}
},
},
// Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers.
customEvent
:
{
"getData"
:
true
,
"setData"
:
true
,
"changeData"
:
true
},
trigger
:
function
(
event
,
data
,
elem
)
{
trigger
:
function
(
event
,
data
,
elem
)
{
// Event object or event type
// Event object or event type
...
@@ -293,7 +301,7 @@ jQuery.event = {
...
@@ -293,7 +301,7 @@ jQuery.event = {
jQuery
.
Event
(
type
);
jQuery
.
Event
(
type
);
if
(
type
.
indexOf
(
"!"
)
>=
0
)
{
if
(
type
.
indexOf
(
"!"
)
>=
0
)
{
// Exclusive events trigger only for the bare event type (no namespaces)
// Exclusive events trigger only for the bare event type (no namespaces)
event
.
type
=
type
=
type
.
slice
(
0
,
-
1
);
event
.
type
=
type
=
type
.
slice
(
0
,
-
1
);
event
.
exclusive
=
true
;
event
.
exclusive
=
true
;
}
}
...
@@ -305,7 +313,12 @@ jQuery.event = {
...
@@ -305,7 +313,12 @@ jQuery.event = {
}
}
event
.
namespace
=
namespaces
.
join
(
"."
);
event
.
namespace
=
namespaces
.
join
(
"."
);
event
.
namespace_re
=
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
join
(
"
\\
.(?:.*
\\
.)?"
)
+
"(
\\
.|$)"
);
event
.
namespace_re
=
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
join
(
"
\\
.(?:.*
\\
.)?"
)
+
"(
\\
.|$)"
);
if
(
jQuery
.
event
.
customEvent
[
type
]
&&
!
jQuery
.
event
.
global
[
type
]
)
{
// No jQuery handlers for this event type, and it can't have inline handlers
return
;
}
// Handle a global trigger
// Handle a global trigger
if
(
!
elem
)
{
if
(
!
elem
)
{
// Don't bubble custom events when global (to avoid too much overhead)
// Don't bubble custom events when global (to avoid too much overhead)
...
...
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