refactor(core): remove direct accesses to DOM

Closes #713
This commit is contained in:
Marc Laval
2015-02-19 11:18:23 +01:00
committed by Misko Hevery
parent 3496c8ac54
commit 89b3995756
11 changed files with 84 additions and 29 deletions

View File

@ -12,8 +12,9 @@ export function getStringParameter(name:string) {
for (var i=0; i<els.length; i++) {
el = els[i];
if ((el.type !== 'radio' && el.type !== 'checkbox') || el.checked) {
value = el.value;
var type = DOM.type(el);
if ((type !== 'radio' && type !== 'checkbox') || DOM.getChecked(el)) {
value = DOM.getValue(el);
break;
}
}

View File

@ -151,12 +151,12 @@ export class SpyObject {
function elementText(n) {
var hasShadowRoot = (n) => n instanceof Element && n.shadowRoot;
var hasNodes = (n) => n.childNodes && n.childNodes.length > 0;
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("");
if (n instanceof Element && n.tagName == 'CONTENT')
if (n instanceof Element && DOM.tagName(n) == 'CONTENT')
return elementText(Array.prototype.slice.apply(n.getDistributedNodes()));
if (hasShadowRoot(n)) return elementText(DOM.childNodesAsList(n.shadowRoot));
if (hasNodes(n)) return elementText(DOM.childNodesAsList(n));

View File

@ -39,5 +39,5 @@ export function dispatchEvent(element, eventType) {
}
export function el(html) {
return DOM.firstChild(DOM.createTemplate(html).content);
return DOM.firstChild(DOM.content(DOM.createTemplate(html)));
}