- Catch exception when IE8 using the native implementation fais, in order to failback to js selectors (fixes issue45)
- Change javascript code for the property-provider selectorCapability to use $doc instead of document
values="native,js"/>\r
<property-provider name="selectorCapability">\r
<![CDATA[\r
- // useful for benchmarking tests when you want to force non-accelerated queries\r
- if(window.location.href.indexOf("_selector_force_js") != -1) return "js"; \r
- if(document.querySelectorAll && /native/.test(String(document.querySelectorAll))) return "native";\r
+ // Select javascript permutation when the user wants to\r
+ // force non-accelerated queries (for benchmarking tests)\r
+ if ($doc.location.href.indexOf("_selector_force_js") != -1) \r
+ return "js"; \r
+ \r
+ // Select the native permutation if querySelectorAll is available\r
+ if ($doc.querySelectorAll && /native/.test(String($doc.querySelectorAll))) \r
+ return "native";\r
+ \r
return "js";\r
]]>\r
</property-provider>\r
</any>\r
</replace-with>\r
\r
- <replace-with class="com.google.gwt.query.client.impl.SelectorEngineNativeIE8">\r
+ <replace-with class="com.google.gwt.query.client.impl.SelectorEngineNative">\r
<when-type-assignable class="com.google.gwt.query.client.impl.SelectorEngineImpl"/>\r
<when-property-is name="selectorCapability" value="native"/>\r
</replace-with>\r
<when-property-is name="selectorCapability" value="native"/>\r
<when-property-is name="user.agent" value="ie8"/>\r
</replace-with>\r
-
- <define-linker name="stddoctype" class="com.google.gwt.query.linker.IFrameWithDocTypeLinker"/>
- <add-linker name="stddoctype"/>
-\r
+ \r
+ <define-linker name="stddoctype" class="com.google.gwt.query.linker.IFrameWithDocTypeLinker"/>\r
+ <add-linker name="stddoctype"/>\r
+
<entry-point class='com.google.gwt.query.client.css.CSS'/>\r
\r
</module>\r
public static native Node getPreviousSibling(Node n) /*-{\r
return n.previousSibling || null; \r
}-*/;\r
+ \r
+ private static boolean degradate = false;\r
+ \r
+ public NodeList<Element> querySelectorAllIE8(String selector, Node ctx) {\r
+ if (degradate) {\r
+ return impl.select(selector, ctx);\r
+ } \r
+ try {\r
+ return querySelectorAll(selector, ctx);\r
+ } catch (Exception e) {\r
+ System.out.println("IE8 Degradating to dynamic implementation, it seems IE8 is not running in standars mode");\r
+ degradate = true;\r
+ return querySelectorAll(selector, ctx);\r
+ }\r
+ }\r
\r
public static native NodeList<Element> querySelectorAll(String selector,\r
Node ctx) /*-{\r
\r
public SelectorEngine() {\r
impl = (SelectorEngineImpl) GWT.create(SelectorEngineImpl.class);\r
+ // System.out.println("SelectorEngineImpl used: " + impl.getClass().getName());\r
}\r
\r
public Node getRoot() {\r
public class SelectorEngineNativeIE8 extends SelectorEngineSizzle {
public static String NATIVE_EXCEPTIONS_REGEXP = ".*(:contains|!=|:checked|:not|:nth-|:last-|:only-).*";
+
+ private static boolean degradate = false;
public NodeList<Element> select(String selector, Node ctx) {
- if (selector.matches(NATIVE_EXCEPTIONS_REGEXP)) {
+ if (degradate || selector.matches(NATIVE_EXCEPTIONS_REGEXP)) {
return super.select(selector, ctx);
} else {
- return SelectorEngine.querySelectorAll(selector, ctx);
+ try {
+ return SelectorEngine.querySelectorAll(selector, ctx);
+ } catch (Exception e) {
+ System.out.println("IE8 Degradating to dynamic implementation, it seems IE8 is not running in standars mode");
+ degradate = true;
+ return super.select(selector, ctx);
+ }
}
}
+
}
super.generateMethodBody(sw, method, treeLogger, hasContext);\r
} else {\r
sw.println("return "\r
- + wrap(method, "querySelectorAll(\"" + selector + "\", root)") + ";");\r
+ + wrap(method, "querySelectorAllIE8(\"" + selector + "\", root)") + ";");\r
}\r
}\r
\r