parent
87549c77d4
commit
564642d859
|
@ -321,16 +321,16 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
List<Node> getElementsByTagName(Element element, String name) =>
|
||||
element.querySelectorAll(name);
|
||||
List<String> classList(Element element) => element.classes.toList();
|
||||
void addClass(Element element, String classname) {
|
||||
element.classes.add(classname);
|
||||
void addClass(Element element, String className) {
|
||||
element.classes.add(className);
|
||||
}
|
||||
|
||||
void removeClass(Element element, String classname) {
|
||||
element.classes.remove(classname);
|
||||
void removeClass(Element element, String className) {
|
||||
element.classes.remove(className);
|
||||
}
|
||||
|
||||
bool hasClass(Element element, String classname) =>
|
||||
element.classes.contains(classname);
|
||||
bool hasClass(Element element, String className) =>
|
||||
element.classes.contains(className);
|
||||
|
||||
void setStyle(Element element, String styleName, String styleValue) {
|
||||
element.style.setProperty(styleName, styleValue);
|
||||
|
|
|
@ -199,11 +199,11 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
return element.getElementsByTagName(name);
|
||||
}
|
||||
classList(element): any[] { return <any[]>Array.prototype.slice.call(element.classList, 0); }
|
||||
addClass(element, classname: string) { element.classList.add(classname); }
|
||||
removeClass(element, classname: string) { element.classList.remove(classname); }
|
||||
hasClass(element, classname: string): boolean { return element.classList.contains(classname); }
|
||||
setStyle(element, stylename: string, stylevalue: string) {
|
||||
element.style[stylename] = stylevalue;
|
||||
addClass(element, className: string) { element.classList.add(className); }
|
||||
removeClass(element, className: string) { element.classList.remove(className); }
|
||||
hasClass(element, className: string): boolean { return element.classList.contains(className); }
|
||||
setStyle(element, styleName: string, styleValue: string) {
|
||||
element.style[styleName] = styleValue;
|
||||
}
|
||||
removeStyle(element, stylename: string) { element.style[stylename] = null; }
|
||||
getStyle(element, stylename: string): string { return element.style[stylename]; }
|
||||
|
|
|
@ -83,9 +83,9 @@ export abstract class DomAdapter {
|
|||
abstract getElementsByClassName(element, name: string): HTMLElement[];
|
||||
abstract getElementsByTagName(element, name: string): HTMLElement[];
|
||||
abstract classList(element): any[];
|
||||
abstract addClass(element, classname: string);
|
||||
abstract removeClass(element, classname: string);
|
||||
abstract hasClass(element, classname: string): boolean;
|
||||
abstract addClass(element, className: string);
|
||||
abstract removeClass(element, className: string);
|
||||
abstract hasClass(element, className: string): boolean;
|
||||
abstract setStyle(element, styleName: string, styleValue: string);
|
||||
abstract removeStyle(element, styleName: string);
|
||||
abstract getStyle(element, styleName: string): string;
|
||||
|
|
|
@ -253,15 +253,15 @@ abstract class AbstractHtml5LibAdapter implements DomAdapter {
|
|||
|
||||
List classList(element) => element.classes.toList();
|
||||
|
||||
addClass(element, String classname) {
|
||||
element.classes.add(classname);
|
||||
addClass(element, String className) {
|
||||
element.classes.add(className);
|
||||
}
|
||||
|
||||
removeClass(element, String classname) {
|
||||
removeClass(element, String className) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
hasClass(element, String classname) => element.classes.contains(classname);
|
||||
hasClass(element, String className) => element.classes.contains(className);
|
||||
|
||||
setStyle(element, String styleName, String styleValue) {
|
||||
throw 'not implemented';
|
||||
|
|
|
@ -352,24 +352,24 @@ export class Parse5DomAdapter extends DomAdapter {
|
|||
}
|
||||
return classAttrValue ? classAttrValue.trim().split(/\s+/g) : [];
|
||||
}
|
||||
addClass(element, classname: string) {
|
||||
addClass(element, className: string) {
|
||||
var classList = this.classList(element);
|
||||
var index = classList.indexOf(classname);
|
||||
var index = classList.indexOf(className);
|
||||
if (index == -1) {
|
||||
classList.push(classname);
|
||||
classList.push(className);
|
||||
element.attribs["class"] = element.className = classList.join(" ");
|
||||
}
|
||||
}
|
||||
removeClass(element, classname: string) {
|
||||
removeClass(element, className: string) {
|
||||
var classList = this.classList(element);
|
||||
var index = classList.indexOf(classname);
|
||||
var index = classList.indexOf(className);
|
||||
if (index > -1) {
|
||||
classList.splice(index, 1);
|
||||
element.attribs["class"] = element.className = classList.join(" ");
|
||||
}
|
||||
}
|
||||
hasClass(element, classname: string): boolean {
|
||||
return ListWrapper.contains(this.classList(element), classname);
|
||||
hasClass(element, className: string): boolean {
|
||||
return ListWrapper.contains(this.classList(element), className);
|
||||
}
|
||||
hasStyle(element, styleName: string, styleValue: string = null): boolean {
|
||||
var value = this.getStyle(element, styleName) || '';
|
||||
|
|
Loading…
Reference in New Issue