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
98bd178c
Commit
98bd178c
authored
Jul 16, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the parsing engine extensible.
parent
f5f6cbc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
37 deletions
+40
-37
jquery.js
jquery/jquery.js
+40
-37
No files found.
jquery/jquery.js
View file @
98bd178c
...
@@ -1405,50 +1405,53 @@ jQuery.extend({
...
@@ -1405,50 +1405,53 @@ jQuery.extend({
}
else
}
else
return
""
;
return
""
;
},
},
// The regular expressions that power the parsing engine
parse
:
[
// Match: [@value='test'], [@foo]
"
\\
[ *(@)S *([!*$^=]*) *Q
\\
]"
,
// Match: [div], [div p]
"(
\\
[)Q
\\
]"
,
// Match: :contains('foo')
"(:)S
\\
(Q
\\
)"
,
// Match: :even, :last-chlid
"([:.#]*)S"
],
parseSwap
:
[
1
,
0
,
0
,
0
],
filter
:
function
(
t
,
r
,
not
)
{
filter
:
function
(
t
,
r
,
not
)
{
// Figure out if we're doing regular, or inverse, filtering
// Figure out if we're doing regular, or inverse, filtering
var
g
=
not
!==
false
?
jQuery
.
grep
:
var
g
=
not
!==
false
?
jQuery
.
grep
:
function
(
a
,
f
)
{
return
jQuery
.
grep
(
a
,
f
,
true
);};
function
(
a
,
f
)
{
return
jQuery
.
grep
(
a
,
f
,
true
);};
// Look for a string-like sequence
while
(
t
&&
/^
[
a-z[({<*:.#
]
/i
.
test
(
t
)
)
{
var
str
=
"([a-zA-Z*_-][a-zA-Z0-9_-]*)"
;
for
(
var
i
=
0
;
i
<
jQuery
.
parse
.
length
;
i
++
)
{
// Look for something (optionally) enclosed with quotes
var
re
=
new
RegExp
(
"^"
+
jQuery
.
parse
[
i
]
var
qstr
=
" *'?
\"
?([^'
\"
]*)'?
\"
? *"
;
// Look for a string-like sequence
while
(
t
&&
/^
[
a-zA-Z
\[
*:.#
]
/
.
test
(
t
)
)
{
.
replace
(
'S'
,
"([a-z*_-][a-z0-9_-]*)"
)
// Handles:
// [@foo], [@foo=bar], etc.
// Look for something (optionally) enclosed with quotes
var
re
=
new
RegExp
(
"^
\\
[ *@"
+
str
+
" *([!*$^=]*) *"
+
qstr
+
"
\\
]"
);
.
replace
(
'Q'
,
" *'?
\"
?([^'
\"
]*)'?
\"
? *"
),
"i"
);
var
m
=
re
.
exec
(
t
);
var
m
=
re
.
exec
(
t
);
// Re-organize the match
if
(
m
)
m
=
[
""
,
"@"
,
m
[
2
],
m
[
1
],
m
[
3
]];
if
(
m
)
{
// Re-organize the match
// Handles:
if
(
jQuery
.
parseSwap
[
i
]
)
// [div], [.foo]
m
=
[
""
,
m
[
1
],
m
[
3
],
m
[
2
],
m
[
4
]];
if
(
!
m
)
{
re
=
new
RegExp
(
"^(
\\
[)"
+
qstr
+
"
\\
]"
);
// Remove what we just matched
m
=
re
.
exec
(
t
);
t
=
t
.
replace
(
re
,
""
);
}
break
;
// Handles:
}
// :contains(test), :not(.foo)
if
(
!
m
)
{
re
=
new
RegExp
(
"^(:)"
+
str
+
"
\\
("
+
qstr
+
"
\\
)"
);
m
=
re
.
exec
(
t
);
}
// Handles:
// :foo, .foo, #foo, foo
if
(
!
m
)
{
re
=
new
RegExp
(
"^([:.#]*)"
+
str
);
m
=
re
.
exec
(
t
);
}
}
// Remove what we just matched
t
=
t
.
replace
(
re
,
""
);
// :not() is a special case that can be optomized by
// :not() is a special case that can be optomized by
// keeping it out of the expression list
// keeping it out of the expression list
...
...
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