fix(test_lib): remove getDistributedNodes emulation in NodeJS
This commit is contained in:
@ -153,9 +153,8 @@ export class SpyObject {
|
||||
|
||||
|
||||
function elementText(n) {
|
||||
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
||||
if (!IS_NODEJS) {
|
||||
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
||||
|
||||
if (n instanceof Comment) return '';
|
||||
|
||||
if (n instanceof Array) return n.map((nn) => elementText(nn)).join("");
|
||||
@ -166,33 +165,10 @@ function elementText(n) {
|
||||
|
||||
return n.textContent;
|
||||
} else {
|
||||
if (DOM.hasShadowRoot(n)) {
|
||||
return elementText(DOM.getShadowRoot(n).childNodes);
|
||||
} else if (n instanceof Array) {
|
||||
if (n instanceof Array) {
|
||||
return n.map((nn) => elementText(nn)).join("");
|
||||
} else if (DOM.tagName(n) == 'content') {
|
||||
//minimal implementation of getDistributedNodes()
|
||||
var host = null;
|
||||
var temp = n;
|
||||
while (temp.parent) {
|
||||
if (DOM.hasShadowRoot(temp)) {
|
||||
host = temp;
|
||||
}
|
||||
temp = temp.parent;
|
||||
}
|
||||
if (host) {
|
||||
var list = [];
|
||||
var select = DOM.getAttribute(n, "select");
|
||||
var selectClass = select? select.substring(1): null;
|
||||
DOM.childNodes(host).forEach((child) => {
|
||||
var classList = DOM.classList(child);
|
||||
if (selectClass && classList.indexOf(selectClass) > -1 || selectClass == null && classList.length == 0) {
|
||||
list.push(child);
|
||||
}
|
||||
});
|
||||
return list.length > 0? elementText(list): "";
|
||||
}
|
||||
return "";
|
||||
} else if (hasNodes(n)) {
|
||||
return elementText(DOM.childNodesAsList(n));
|
||||
} else {
|
||||
return DOM.getText(n);
|
||||
}
|
||||
|
Reference in New Issue
Block a user