- if(nodeElementParent) {
- parent = {
- repr: wlxmlUtils.wlxmlTagNames[nodeElementParent.getTagName()] + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.wlxmlClassNames[nodeElementParent.getClass()] : '')
- };
- }
-
- var nodeContents = nodeElement.contents(),
- contents = [];
- nodeContents.forEach(function(child) {
- if(child.getText) {
- var text = child.getText();
- if(!text)
- text = '<pusty tekst>';
- else {
- if(text.length > 13) {
- text = text.substr(0,13) + '...';
+ if(element) {
+ element = element || this.currentNodeElement;
+ var textElement = element.getText ? element : null,
+ nodeElement = element.getText ? element.parent() : element, // TODO: better type detection
+ items;
+
+ this.currentNodeElement = nodeElement;
+ items = [];
+ nodeElementParent = nodeElement.parent();
+
+ if(nodeElementParent) {
+ items.push(nodeElementParent);
+ parent = {
+ id: items.length - 1,
+ repr: wlxmlUtils.getTagLabel(nodeElementParent.getTagName()) + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.getClassLabel(nodeElementParent.getClass()) : '')
+ };
+
+ }
+
+ var nodeContents = nodeElement.contents();
+ nodeContents.forEach(function(child) {
+ if(child.getText) {
+ var text = child.getText();
+ if(!text) {
+ text = '<pusty tekst>';
+ }
+ else {
+ if(text.length > 13) {
+ text = text.substr(0,13) + '...';
+ }
+ text = '"' + text + '"';