ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

Using quotes in contains() selector causes exception #121

Closed jDramaix closed 11 years ago

jDramaix commented 11 years ago

Original author: dewi.jo...@gmail.com (July 06, 2011 11:07:38)

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: http://code.google.com/p/gwtquery/issues/detail?id=89

jDramaix commented 11 years ago

From julien.d...@gmail.com on July 06, 2011 21:27:36 Thanks for the bug reporting !

jDramaix commented 11 years ago

This issue is a duplicate of #77