-/**
- * We take child and its parent as arguments separatly to
- * handle situation where child was removed from WLXMLDocument
- * and it lost reference to its parent (but we may still have it on canvas).
-*/
-var findCanvasElementInParent = function(wlxmlChildNode, wlxmlParentNode) {
- var parentElement, toret;
+var getElementForNode = function(node, withParent) {
+ if(node.nodeType === Node.TEXT_NODE) {
+ return _getElementForTextNode(node, withParent);
+ }
+ while(!node.getData('canvasElement')) {
+ node = node.parent();
+ }
+ return node.getData('canvasElement');
+};