tel8618217223380 / gwtquery

Automatically exported from code.google.com/p/gwtquery
MIT License
0 stars 0 forks source link

Using quotes in contains() selector causes exception #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. $("div[@class='comment']:contains('John')").css("text-decoration", 
"underline");
2.
3.

What is the expected output? What do you see instead?
As per the jQuery example, http://api.jquery.com/contains-selector, the word 
'John' should be underlined. Instead I'm getting a 
NS_ERROR_DOM_INVALID_EXPRESSION_ERR exception

What version of the product are you using? On what operating system?
GwtQuery 1.0 with GWT 2.3

Please provide any additional information below.
Browser tested in ; Firefox 4.

The reason seems to be using quotes inside the contains function. With quotes, 
the equivalent XPath that the selection engine was using in 
SelectorEngineCssToXPath::select() was:

//div[@class='comment'] and (contains(string(.),''John''))]

which is not valid XPath syntax due to the quotes doubled up around John.

Removing the quotes such that my selector is now similar to:

$("div[@class='comment']:contains(John)").css("text-decoration", "underline");

gives an XPath of //div[@class='comment'] and (contains(string(.),'John'))]

which works

If no quotes is the right way to use gwtQuery contains(), then that's different 
to what jQuery's contains() selector expects. 
(http://api.jquery.com/contains-selector/)

Original issue reported on code.google.com by dewi.jo...@gmail.com on 6 Jul 2011 at 11:07

GoogleCodeExporter commented 9 years ago
Thanks for the bug reporting !

Original comment by julien.d...@gmail.com on 6 Jul 2011 at 9:27

GoogleCodeExporter commented 9 years ago

Original comment by julien.d...@gmail.com on 6 Jul 2011 at 9:28

GoogleCodeExporter commented 9 years ago
This issue is duplicated of #77.
BTW: you have a mistake in your xpath result, it should be 
//div[@class='comment' and (contains(string(.),'John'))]
instead of
//div[@class='comment'] and (contains(string(.),'John'))]

Thanks for reporting
- Manolo

Original comment by manuel.carrasco.m on 8 Jul 2011 at 1:11