fix(test_lib): remove getDistributedNodes emulation in NodeJS
This commit is contained in:
parent
dd3e6271c2
commit
c67194a3ef
|
@ -153,9 +153,8 @@ export class SpyObject {
|
||||||
|
|
||||||
|
|
||||||
function elementText(n) {
|
function elementText(n) {
|
||||||
|
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
||||||
if (!IS_NODEJS) {
|
if (!IS_NODEJS) {
|
||||||
var hasNodes = (n) => {var children = DOM.childNodes(n); return children && children.length > 0;}
|
|
||||||
|
|
||||||
if (n instanceof Comment) return '';
|
if (n instanceof Comment) return '';
|
||||||
|
|
||||||
if (n instanceof Array) return n.map((nn) => elementText(nn)).join("");
|
if (n instanceof Array) return n.map((nn) => elementText(nn)).join("");
|
||||||
|
@ -166,33 +165,10 @@ function elementText(n) {
|
||||||
|
|
||||||
return n.textContent;
|
return n.textContent;
|
||||||
} else {
|
} else {
|
||||||
if (DOM.hasShadowRoot(n)) {
|
if (n instanceof Array) {
|
||||||
return elementText(DOM.getShadowRoot(n).childNodes);
|
|
||||||
} else if (n instanceof Array) {
|
|
||||||
return n.map((nn) => elementText(nn)).join("");
|
return n.map((nn) => elementText(nn)).join("");
|
||||||
} else if (DOM.tagName(n) == 'content') {
|
} else if (hasNodes(n)) {
|
||||||
//minimal implementation of getDistributedNodes()
|
return elementText(DOM.childNodesAsList(n));
|
||||||
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 {
|
} else {
|
||||||
return DOM.getText(n);
|
return DOM.getText(n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib';
|
import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, IS_NODEJS} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {StringMapWrapper, List} from 'angular2/src/facade/collection';
|
import {StringMapWrapper, List} from 'angular2/src/facade/collection';
|
||||||
import {Type} from 'angular2/src/facade/lang';
|
import {Type} from 'angular2/src/facade/lang';
|
||||||
|
@ -40,12 +40,15 @@ export function main() {
|
||||||
var urlResolver = new UrlResolver();
|
var urlResolver = new UrlResolver();
|
||||||
var styleUrlResolver = new StyleUrlResolver(urlResolver);
|
var styleUrlResolver = new StyleUrlResolver(urlResolver);
|
||||||
var styleInliner = new StyleInliner(null, styleUrlResolver, urlResolver);
|
var styleInliner = new StyleInliner(null, styleUrlResolver, urlResolver);
|
||||||
|
var strategies = {
|
||||||
|
"scoped" : new EmulatedScopedShadowDomStrategy(styleInliner, styleUrlResolver, DOM.createElement('div')),
|
||||||
|
"unscoped" : new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, DOM.createElement('div'))
|
||||||
|
}
|
||||||
|
if (!IS_NODEJS) {
|
||||||
|
StringMapWrapper.set(strategies, "native", new NativeShadowDomStrategy(styleUrlResolver));
|
||||||
|
}
|
||||||
|
|
||||||
StringMapWrapper.forEach({
|
StringMapWrapper.forEach(strategies,
|
||||||
"native" : new NativeShadowDomStrategy(styleUrlResolver),
|
|
||||||
"scoped" : new EmulatedScopedShadowDomStrategy(styleInliner, styleUrlResolver, DOM.createElement('div')),
|
|
||||||
"unscoped" : new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, DOM.createElement('div')),
|
|
||||||
},
|
|
||||||
(strategy, name) => {
|
(strategy, name) => {
|
||||||
|
|
||||||
describe(`${name} shadow dom strategy`, () => {
|
describe(`${name} shadow dom strategy`, () => {
|
||||||
|
|
Loading…
Reference in New Issue