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