ArcBees / gwtquery

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

$("*:not(:has(*))") causes crash #144

Closed jDramaix closed 10 years ago

jDramaix commented 11 years ago

Original author: dewi.jo...@gmail.com (November 03, 2011 07:14:41)

What steps will reproduce the problem?

  1. Create a gQuery object with the selection $(":not(:has())")

What is the expected output? What do you see instead? A valid Gquery object containing all elements which do not have descendents. This is what I see instead in Eclipse:

Created HasSelector: com.google.gwt.query.client.impl.SelectorEngineCssToXPath Created SelectorEngineImpl: com.google.gwt.query.client.impl.SelectorEngineNative Created DocumentStyleImpl: com.google.gwt.query.client.impl.DocumentStyleImpl ERROR SelectorEngineNative (NS_ERROR_DOM_SYNTAXERR): An invalid or illegal string was specified :not(:has()), falling back to SelectorEngineCssToXPath ERROR: xpathEvaluate invalid xpath expression:.//[not(.//:has() css-selector::not(:has(_))

com.google.gwt.core.client.JavaScriptException: (NS_ERROR_DOM_INVALID_EXPRESSION_ERR): The expression is not a legal expression. at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.query.client.impl.SelectorEngine.xpathEvaluate(SelectorEngine.java) at com.google.gwt.query.client.impl.SelectorEngineCssToXPath.select(SelectorEngineCssToXPath.java:225) at com.google.gwt.query.client.impl.SelectorEngineNative.select(SelectorEngineNative.java:70) at com.google.gwt.query.client.impl.SelectorEngine.select(SelectorEngine.java:138) at com.google.gwt.query.client.GQuery.select(GQuery.java:3708) at com.google.gwt.query.client.GQuery.$(GQuery.java:291) at com.google.gwt.query.client.GQuery.$(GQuery.java:259)

What version of the product are you using? On what operating system? gQuery 1.1.0

Please provide any additional information below. Firefox and GWT 2.4 in Linux.

Original issue: http://code.google.com/p/gwtquery/issues/detail?id=112

jDramaix commented 11 years ago

From manuel.carrasco.m on November 03, 2011 11:17:40

:has selector is not implemented yet in gquery, it is not a valid css selector, in jquery it is an extension: http://api.jquery.com/has-selector/

We will implement it in a future release, in the meanwhile use gquery methods as a workaround. $("").not($("").has("*"));

The gquery implementation will delegate on these methods as jquery does, so :has cannot take advance of css native selector performance.

manolo commented 10 years ago

We will not implement 'has' pseudo.

'has' implementation in gQuery will reduce performance of other selectors also implies introduce GQuery dependency inside Selector engine.

Since there is a workaround, we prefer gquery users wanting to use the 'has' pseudo-selector to use $("").not($("").has("*")); instead of penalizing all.