feat(compiler): allow setting attributes on a host element
Closes #1402
This commit is contained in:
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
3
modules/angular2/src/dom/dom_adapter.js
vendored
3
modules/angular2/src/dom/dom_adapter.js
vendored
@ -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();
|
||||
}
|
||||
|
@ -211,6 +211,9 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
});
|
||||
return map;
|
||||
}
|
||||
hasAttribute(element, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
getAttribute(element, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user