return name != null ? d.get(name) : id;\r
}\r
\r
- /**\r
- * Set element data. \r
- */\r
- public static Object data(Element e, String key, String value) {\r
- return GQuery.data(e, key, value);\r
- }\r
-\r
/**\r
* Execute a function around each object\r
*/\r
/**\r
* The nodeList of matched elements, modify this using setArray\r
*/\r
+ // TODO: remove this and use elements, change return type of get()\r
private NodeList<Element> nodeList = JavaScriptObject.createArray().cast();\r
\r
private GQuery previousObject;\r
break;\r
}\r
EventsListener.rebind(n.<Element> cast());\r
- \r
// GqUi.attachWidget(w);\r
}\r
}\r
- if (newNodes.size() > g.size()) {\r
+ // TODO: newNodes.size() > g.size() makes testRebind fail\r
+ if (newNodes.size() >= g.size()) {\r
g.setArray(newNodes);\r
}\r
return this;\r
} else if (s.endsWith(":hidden")) {\r
nodes = filterByVisibility(select(s.substring(0, s.length() - 7), ctx), false);\r
} else {\r
- nodes = select(a.get(1) + "[type=" + a.get(2) + "]", ctx);\r
+ nodes = select((a.get(1) != null ? a.get(1) : "") + "[type=" + a.get(2) + "]", ctx);\r
} \r
} else {\r
nodes = select(s, ctx);\r
public void testRebind() {
final GQuery b = $("<p>content</p>");
+ assertEquals(1, b.size());
+ assertEquals(1, b.get().getLength());
b.click(new Function() {
public void f(Element e){
b.css(CSS.COLOR.with(RGBColor.RED));
}
});
$(e).append(b);
+ // TODO: dom manipulations some times modifies gquery nodelist,
+ // we could remove the nodelist since we maintain a list of elements.
+ assertEquals(1, b.size());
+ assertEquals(1, b.get().getLength());
b.click();
assertEquals("red", $(b).css("color", false));
}