}
}.bind(this));
return toret;
+ },
+ getContextRoot: function() {
+ var contextRoot;
+ [this].concat(this.parents()).some(function(n) {
+ if(n.isContextRoot()) {
+ contextRoot = n;
+ return true;
+ }
+ });
+ return contextRoot;
+ },
+ hasSameContextRoot: function(other) {
+ return this.getContextRoot().sameNode(other.getContextRoot());
}
};
return child.is(query);
}.bind(this));
},
+ find: function(query) {
+ var doc = this.document;
+ return this._$.find('*')
+ .map(function() {
+ return doc.createDocumentNode(this);
+ })
+ .filter(function() {
+ return this.is(query);
+ });
+ },
_getXMLDOMToDump: function() {
var DOM = this._$.clone(true, true),
};
WLXMLDocumentNode.prototype = Object.create(smartxml.DocumentNode.prototype);
-
var WLXMLTextNode = function() {
smartxml.TextNode.apply(this, arguments);
};
metadataNode.remove();
});
nativeNode.normalize();
+ $(nativeNode).find('*').each(function() {
+ if (this.childNodes.length === 0) {
+ var fakeTextNode = window.document.createTextNode("");
+ this.appendChild(fakeTextNode);
+ }
+ });
$(nativeNode).find(':not(iframe)').addBack().contents()
.filter(function() {return this.nodeType === Node.TEXT_NODE;})
elParent = el.parent(),
hasSpanParent = elParent.prop('tagName') === 'SPAN',
hasSpanBefore = el.prev().length && $(el.prev()).prop('tagName') === 'SPAN',
- hasSpanAfter = el.next().length && $(el.next()).prop('tagName') === 'SPAN';
+ hasSpanAfter = el.next().length && $(el.next()).prop('tagName') === 'SPAN',
+ onlyChild = el.is(':only-child');
var addInfo = function(toAdd, where, transformed, original) {
}
}
- if(!text.transformed) {
+ if(!text.transformed && !onlyChild) {
addInfo(text.original, 'below');
el.remove();
return true; // continue