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
2fac5e79
Commit
2fac5e79
authored
Apr 13, 2007
by
Corey Jewett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RegExp style xpath attributes and testcases. e.g. [@foo =~ /bar/i] and [@foo !~ /bar/]
parent
bfe5f891
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
selector.js
src/selector/selector.js
+4
-1
selectorTest.js
src/selector/selectorTest.js
+3
-1
No files found.
src/selector/selector.js
View file @
2fac5e79
...
@@ -56,6 +56,9 @@ jQuery.extend({
...
@@ -56,6 +56,9 @@ jQuery.extend({
"$="
:
"z&&z.substr(z.length - m[4].length,m[4].length)==m[4]"
,
"$="
:
"z&&z.substr(z.length - m[4].length,m[4].length)==m[4]"
,
"*="
:
"z&&z.indexOf(m[4])>=0"
,
"*="
:
"z&&z.indexOf(m[4])>=0"
,
""
:
"z"
,
""
:
"z"
,
// these are for evaling in a regexp.
"=~"
:
"eval(m[4]).test(z)"
,
"!~"
:
"!eval(m[4]).test(z)"
,
_resort
:
function
(
m
){
_resort
:
function
(
m
){
return
[
""
,
m
[
1
],
m
[
3
],
m
[
2
],
m
[
5
]];
return
[
""
,
m
[
1
],
m
[
3
],
m
[
2
],
m
[
5
]];
},
},
...
@@ -67,7 +70,7 @@ jQuery.extend({
...
@@ -67,7 +70,7 @@ jQuery.extend({
// The regular expressions that power the parsing engine
// The regular expressions that power the parsing engine
parse
:
[
parse
:
[
// Match: [@value='test'], [@foo]
// Match: [@value='test'], [@foo]
/^
\[
*
(
@
)([\w
-
]
+
)
*
([
!*$^=
]
*
)
*
(
'
?
"
?)(
.*
?)\4
*
\]
/
,
/^
\[
*
(
@
)([\w
-
]
+
)
*
([
!*$^=
!~
]
*
)
*
(
'
?
"
?)(
.*
?)\4
*
\]
/
,
// Match: [div], [div p]
// Match: [div], [div p]
/^
(\[)\s
*
(
.*
?(\[
.*
?\])?[^
[
]
*
?)\s
*
\]
/
,
/^
(\[)\s
*
(
.*
?(\[
.*
?\])?[^
[
]
*
?)\s
*
\]
/
,
...
...
src/selector/selectorTest.js
View file @
2fac5e79
...
@@ -183,7 +183,7 @@ test("pseudo (:) selectors", function() {
...
@@ -183,7 +183,7 @@ test("pseudo (:) selectors", function() {
});
});
test
(
"basic xpath"
,
function
()
{
test
(
"basic xpath"
,
function
()
{
expect
(
1
5
);
expect
(
1
7
);
ok
(
jQuery
.
find
(
"//*"
).
length
>=
30
,
"All Elements (//*)"
);
ok
(
jQuery
.
find
(
"//*"
).
length
>=
30
,
"All Elements (//*)"
);
t
(
"All Div Elements"
,
"//div"
,
[
"main"
,
"foo"
]
);
t
(
"All Div Elements"
,
"//div"
,
[
"main"
,
"foo"
]
);
t
(
"Absolute Path"
,
"/html/body"
,
[
"body"
]
);
t
(
"Absolute Path"
,
"/html/body"
,
[
"body"
]
);
...
@@ -194,6 +194,8 @@ test("basic xpath", function() {
...
@@ -194,6 +194,8 @@ test("basic xpath", function() {
t
(
"All Children, Implicit"
,
"//code/"
,
[
"anchor1"
,
"anchor2"
]
);
t
(
"All Children, Implicit"
,
"//code/"
,
[
"anchor1"
,
"anchor2"
]
);
t
(
"Attribute Exists"
,
"//a[@title]"
,
[
"google"
]
);
t
(
"Attribute Exists"
,
"//a[@title]"
,
[
"google"
]
);
t
(
"Attribute Equals"
,
"//a[@rel='bookmark']"
,
[
"simon1"
]
);
t
(
"Attribute Equals"
,
"//a[@rel='bookmark']"
,
[
"simon1"
]
);
t
(
"Attribute RegExp"
,
"//a[@rel=~/BooKmaRk/i]"
,
[
"simon1"
]
);
t
(
"Attribute Inverse RegExp"
,
"//a[@id!~/mon/]"
,
[
"google"
,
"groups"
,
"anchor1"
,
"mark"
,
"yahoo"
,
"anchor2"
]
);
t
(
"Parent Axis"
,
"//p/.."
,
[
"main"
,
"foo"
]
);
t
(
"Parent Axis"
,
"//p/.."
,
[
"main"
,
"foo"
]
);
t
(
"Sibling Axis"
,
"//p/../"
,
[
"firstp"
,
"ap"
,
"foo"
,
"first"
,
"firstUL"
,
"empty"
,
"form"
,
"floatTest"
,
"iframe"
,
"lengthtest"
,
"sndp"
,
"en"
,
"sap"
]
);
t
(
"Sibling Axis"
,
"//p/../"
,
[
"firstp"
,
"ap"
,
"foo"
,
"first"
,
"firstUL"
,
"empty"
,
"form"
,
"floatTest"
,
"iframe"
,
"lengthtest"
,
"sndp"
,
"en"
,
"sap"
]
);
t
(
"Sibling Axis"
,
"//p/../*"
,
[
"firstp"
,
"ap"
,
"foo"
,
"first"
,
"firstUL"
,
"empty"
,
"form"
,
"floatTest"
,
"iframe"
,
"lengthtest"
,
"sndp"
,
"en"
,
"sap"
]
);
t
(
"Sibling Axis"
,
"//p/../*"
,
[
"firstp"
,
"ap"
,
"foo"
,
"first"
,
"firstUL"
,
"empty"
,
"form"
,
"floatTest"
,
"iframe"
,
"lengthtest"
,
"sndp"
,
"en"
,
"sap"
]
);
...
...
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