feat(compiler): initial version of the compiler.
Supports: - binds text nodes, element properties and directive properties - locates decorator, component and template directives. - inline templates of components The compiler is built using a pipeline design, see core/src/compiler/pipeline package. Integration tests to show how the compiler, change_detection and DI work together: core/test/compiler/integration_spec.js
This commit is contained in:
@ -4,7 +4,7 @@ export var NodeList = window.NodeList;
|
||||
export var Text = window.Text;
|
||||
export var Element = window.HTMLElement;
|
||||
export var TemplateElement = window.HTMLTemplateElement;
|
||||
import {List} from 'facade/collection';
|
||||
import {List, MapWrapper} from 'facade/collection';
|
||||
|
||||
export class DOM {
|
||||
static query(selector) {
|
||||
@ -19,12 +19,21 @@ export class DOM {
|
||||
static getInnerHTML(el) {
|
||||
return el.innerHTML;
|
||||
}
|
||||
static getOuterHTML(el) {
|
||||
return el.outerHTML;
|
||||
}
|
||||
static firstChild(el):Node {
|
||||
return el.firstChild;
|
||||
}
|
||||
static parentElement(el) {
|
||||
return el.parentElement;
|
||||
}
|
||||
static childNodes(el):NodeList {
|
||||
return el.childNodes;
|
||||
}
|
||||
static appendChild(el, node) {
|
||||
el.appendChild(node);
|
||||
}
|
||||
static setInnerHTML(el, value) {
|
||||
el.innerHTML = value;
|
||||
}
|
||||
@ -42,10 +51,32 @@ export class DOM {
|
||||
static setProperty(element:Element, name:string, value) {
|
||||
element[name] = value;
|
||||
}
|
||||
static getProperty(element:Element, name:string) {
|
||||
return element[name];
|
||||
}
|
||||
static getElementsByClassName(element:Element, name:string) {
|
||||
return element.getElementsByClassName(name);
|
||||
}
|
||||
static getElementsByTagName(element:Element, name:string) {
|
||||
return element.getElementsByTagName(name);
|
||||
}
|
||||
static classList(element:Element):List {
|
||||
return Array.prototype.slice.call(element.classList, 0);
|
||||
}
|
||||
static addClass(element:Element, classname:string) {
|
||||
element.classList.add(classname);
|
||||
}
|
||||
static hasClass(element:Element, classname:string) {
|
||||
return element.classList.contains(classname);
|
||||
}
|
||||
static attributeMap(element:Element) {
|
||||
var res = MapWrapper.create();
|
||||
var elAttrs = element.attributes;
|
||||
for (var i = 0; i < elAttrs.length; i++) {
|
||||
var attrib = elAttrs[i];
|
||||
MapWrapper.set(res, attrib.name, attrib.value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user