feat(compiler): allow setting attributes on a host element

Closes #1402
This commit is contained in:
Pawel Kozlowski
2015-05-01 13:41:56 +02:00
parent 7225416661
commit 51839ca677
12 changed files with 107 additions and 1 deletions

View File

@ -248,6 +248,9 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
return new Map.from(element.attributes);
}
bool hasAttribute(Element element, String attribute) =>
element.attributes.containsKey(attribute);
String getAttribute(Element element, String attribute) =>
element.getAttribute(attribute);

View File

@ -263,6 +263,9 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
return res;
}
hasAttribute(element, attribute:string) {
return element.hasAttribute(attribute);
}
getAttribute(element, attribute:string) {
return element.getAttribute(attribute);
}

View File

@ -199,6 +199,9 @@ export class DomAdapter {
attributeMap(element) {
throw _abstract();
}
hasAttribute(element, attribute:string):boolean {
throw _abstract();
}
getAttribute(element, attribute:string):string {
throw _abstract();
}

View File

@ -211,6 +211,9 @@ class Html5LibDomAdapter implements DomAdapter {
});
return map;
}
hasAttribute(element, String attribute) {
throw 'not implemented';
}
getAttribute(element, String attribute) {
throw 'not implemented';
}

View File

@ -384,6 +384,9 @@ export class Parse5DomAdapter extends DomAdapter {
}
return res;
}
hasAttribute(element, attribute:string) {
return element.attribs && element.attribs.hasOwnProperty(attribute);
}
getAttribute(element, attribute:string) {
return element.attribs && element.attribs.hasOwnProperty(attribute)? element.attribs[attribute]: null;
}