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
bb1081ee
Commit
bb1081ee
authored
Aug 14, 2011
by
Dave Methvin
Committed by
timmywil
Sep 19, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the quick selector expression parsing code.
parent
990c094f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
24 deletions
+27
-24
event.js
src/event.js
+27
-24
No files found.
src/event.js
View file @
bb1081ee
...
@@ -7,12 +7,32 @@ var rnamespaces = /\.(.*)$/,
...
@@ -7,12 +7,32 @@ var rnamespaces = /\.(.*)$/,
rescape
=
/
[^\w\s
.|`
]
/g
,
rescape
=
/
[^\w\s
.|`
]
/g
,
rtypenamespace
=
/^
([^\.]
*
)?(?:\.(
.+
))?
$/
,
rtypenamespace
=
/^
([^\.]
*
)?(?:\.(
.+
))?
$/
,
rhoverHack
=
/
\b
hover
(\.\S
+
)?
/
,
rhoverHack
=
/
\b
hover
(\.\S
+
)?
/
,
rquickIs
=
/^
([\w\-]
+
)?(?:
#
([\w\-]
+
))?(?:\.([\w\-]
+
))?(?:\[([\w
+
\-]
+
)
=
[
"'
]?([\w\-]
*
)[
"'
]?\])?(
:first-child|:last-child|:empty
)?
$/
,
rquickIs
=
/^
([\w\-]
+
)?(?:
#
([\w\-]
+
))?(?:\.([\w\-]
+
))?(?:\[([\w
+
\-]
+
)
=
[
"'
]?([\w\-]
*
)[
"'
]?\])?(
?:
:
(
first-child|last-child|empty
)
)?
$/
,
quickPseudoMap
=
{
quickPseudoMap
=
{
":empty"
:
"firstChild"
,
"empty"
:
"firstChild"
,
":first-child"
:
"previousSibling"
,
"first-child"
:
"previousSibling"
,
":last-child"
:
"nextSibling"
"last-child"
:
"nextSibling"
};
},
quickParse
=
function
(
selector
)
{
var
quick
=
rquickIs
.
exec
(
selector
);
if
(
quick
)
{
// 0 1 2 3 4 5 6
// [ _, tag, id, class, attrName, attrValue, pseudo(:empty :first-child :last-child) ]
quick
[
1
]
=
(
quick
[
1
]
||
""
).
toLowerCase
();
quick
[
3
]
=
quick
[
3
]
&&
new
RegExp
(
"
\\
b"
+
quick
[
3
]
+
"
\\
b"
);
quick
[
6
]
=
quickPseudoMap
[
quick
[
6
]
];
}
return
quick
;
},
quickIs
=
function
(
elem
,
m
)
{
return
(
(
!
m
[
1
]
||
elem
.
nodeName
.
toLowerCase
()
===
m
[
1
])
&&
(
!
m
[
2
]
||
elem
.
id
===
m
[
2
])
&&
(
!
m
[
3
]
||
m
[
3
].
test
(
elem
.
className
))
&&
(
!
m
[
4
]
||
elem
.
getAttribute
(
m
[
4
]
)
==
m
[
5
])
&&
(
!
m
[
6
]
||
!
elem
[
m
[
6
]
])
);
}
function
useNativeMethod
(
event
)
{
function
useNativeMethod
(
event
)
{
if
(
!
event
.
isDefaultPrevented
()
&&
this
[
event
.
type
]
)
{
if
(
!
event
.
isDefaultPrevented
()
&&
this
[
event
.
type
]
)
{
...
@@ -91,14 +111,8 @@ jQuery.event = {
...
@@ -91,14 +111,8 @@ jQuery.event = {
// Delegated event setup
// Delegated event setup
if
(
selector
)
{
if
(
selector
)
{
// Pre-analyze selector so we can process it quickly on event dispatch
// Pre-analyze selector so we can process it quickly on event dispatch
quick
=
handleObj
.
quick
=
rquickIs
.
exec
(
selector
);
handleObj
.
quick
=
quickParse
(
selector
);
if
(
quick
)
{
if
(
!
handleObj
.
quick
&&
jQuery
.
expr
.
match
.
POS
.
test
(
selector
)
)
{
// 0 1 2 3 4 5 6
// [ _, tag, id, class, attrName, attrValue, pseudo(:empty :first-child :last-child) ]
quick
[
1
]
=
(
quick
[
1
]
||
""
).
toLowerCase
();
quick
[
3
]
=
quick
[
3
]
&&
new
RegExp
(
"
\\
b"
+
quick
[
3
]
+
"
\\
b"
);
quick
[
6
]
=
quickPseudoMap
[
quick
[
6
]
];
}
else
if
(
jQuery
.
expr
.
match
.
POS
.
test
(
selector
)
)
{
handleObj
.
isPositional
=
true
;
handleObj
.
isPositional
=
true
;
}
}
}
}
...
@@ -584,17 +598,6 @@ function dispatch( target, event, handlers, args ) {
...
@@ -584,17 +598,6 @@ function dispatch( target, event, handlers, args ) {
}
}
}
}
function
quickIs
(
elem
,
m
)
{
return
(
(
!
m
[
1
]
||
elem
.
nodeName
.
toLowerCase
()
===
m
[
1
])
&&
(
!
m
[
2
]
||
elem
.
id
===
m
[
2
])
&&
(
!
m
[
3
]
||
m
[
3
].
test
(
elem
.
className
))
&&
(
!
m
[
4
]
||
elem
.
getAttribute
(
m
[
4
]
)
==
m
[
5
])
&&
(
!
m
[
6
]
||
!
elem
[
m
[
6
]
])
);
}
jQuery
.
removeEvent
=
document
.
removeEventListener
?
jQuery
.
removeEvent
=
document
.
removeEventListener
?
function
(
elem
,
type
,
handle
)
{
function
(
elem
,
type
,
handle
)
{
if
(
elem
.
removeEventListener
)
{
if
(
elem
.
removeEventListener
)
{
...
...
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