public GQuery die(String eventName) {
return as(Events).die(eventName);
}
private GQuery domManip(GQuery g, DomMan type, Element... elms) {
JsNodeArray newNodes = JsNodeArray.create();
if (elms.length == 0) {
elms = elements;
}
for (int i = 0, l = elms.length; i < l; i++) {
Element e = elms[i];
if (e.getNodeType() == Node.DOCUMENT_NODE) {
e = e.<Document> cast().getBody();
}
for (int j = 0, size = g.size(); j < size; j++) {
// Widget w = getAssociatedWidget(g.get(j));
// GqUi.detachWidget(w);
Node n = g.get(j);
// If an element selected is inserted elsewhere, it will be moved into the target (not
// cloned).
// If there is more than one target element, however, cloned copies of the inserted element
// will be created for each target after the first
if (i > 0) {
n = n.cloneNode(true);
}
switch (type) {
case PREPEND:
newNodes.addNode(e.insertBefore(n, e.getFirstChild()));
break;
case APPEND:
newNodes.addNode(e.appendChild(n));
break;
case AFTER:
newNodes.addNode(e.getParentNode().insertBefore(n, e.getNextSibling()));
break;
case BEFORE:
newNodes.addNode(e.getParentNode().insertBefore(n, e));
break;
}
EventsListener.rebind(n.<Element> cast());
// GqUi.attachWidget(w);
}
}
// TODO: newNodes.size() > g.size() makes testRebind fail
if (newNodes.size() >= g.size()) {
g.setArray(newNodes);
}
return this;
}