2015-11-06 17:34:07 -08:00
|
|
|
import {isBlank, Type} from 'angular2/src/facade/lang';
|
2015-05-12 11:19:47 -07:00
|
|
|
|
2015-11-17 15:24:36 -08:00
|
|
|
export var DOM: DomAdapter = null;
|
2015-05-12 11:19:47 -07:00
|
|
|
|
|
|
|
export function setRootDomAdapter(adapter: DomAdapter) {
|
2015-05-19 15:05:02 -07:00
|
|
|
if (isBlank(DOM)) {
|
|
|
|
DOM = adapter;
|
|
|
|
}
|
2015-05-12 11:19:47 -07:00
|
|
|
}
|
|
|
|
|
2015-07-07 20:03:00 -07:00
|
|
|
/* tslint:disable:requireParameterType */
|
2015-05-12 11:19:47 -07:00
|
|
|
/**
|
|
|
|
* Provides DOM operations in an environment-agnostic way.
|
|
|
|
*/
|
2015-09-25 14:48:17 -07:00
|
|
|
export abstract class DomAdapter {
|
|
|
|
abstract hasProperty(element, name: string): boolean;
|
|
|
|
abstract setProperty(el: Element, name: string, value: any);
|
|
|
|
abstract getProperty(el: Element, name: string): any;
|
|
|
|
abstract invoke(el: Element, methodName: string, args: any[]): any;
|
2015-06-18 15:44:44 -07:00
|
|
|
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract logError(error);
|
|
|
|
abstract log(error);
|
|
|
|
abstract logGroup(error);
|
|
|
|
abstract logGroupEnd();
|
2015-05-12 11:19:47 -07:00
|
|
|
|
2015-12-15 16:38:27 -08:00
|
|
|
/** @deprecated */
|
2015-10-14 09:41:15 -07:00
|
|
|
abstract getXHR(): Type;
|
|
|
|
|
2015-05-12 11:19:47 -07:00
|
|
|
/**
|
|
|
|
* Maps attribute names to their corresponding property names for cases
|
|
|
|
* where attribute name doesn't match property name.
|
|
|
|
*/
|
2015-10-02 16:47:54 -07:00
|
|
|
attrToPropMap: {[key: string]: string};
|
2015-05-12 11:19:47 -07:00
|
|
|
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract parse(templateHtml: string);
|
|
|
|
abstract query(selector: string): any;
|
|
|
|
abstract querySelector(el, selector: string): HTMLElement;
|
|
|
|
abstract querySelectorAll(el, selector: string): any[];
|
|
|
|
abstract on(el, evt, listener);
|
|
|
|
abstract onAndCancel(el, evt, listener): Function;
|
|
|
|
abstract dispatchEvent(el, evt);
|
|
|
|
abstract createMouseEvent(eventType): any;
|
|
|
|
abstract createEvent(eventType: string): any;
|
|
|
|
abstract preventDefault(evt);
|
|
|
|
abstract isPrevented(evt): boolean;
|
|
|
|
abstract getInnerHTML(el): string;
|
|
|
|
abstract getOuterHTML(el): string;
|
|
|
|
abstract nodeName(node): string;
|
|
|
|
abstract nodeValue(node): string;
|
|
|
|
abstract type(node): string;
|
|
|
|
abstract content(node): any;
|
|
|
|
abstract firstChild(el): Node;
|
|
|
|
abstract nextSibling(el): Node;
|
|
|
|
abstract parentElement(el): Node;
|
|
|
|
abstract childNodes(el): Node[];
|
|
|
|
abstract childNodesAsList(el): Node[];
|
|
|
|
abstract clearNodes(el);
|
|
|
|
abstract appendChild(el, node);
|
|
|
|
abstract removeChild(el, node);
|
|
|
|
abstract replaceChild(el, newNode, oldNode);
|
|
|
|
abstract remove(el): Node;
|
|
|
|
abstract insertBefore(el, node);
|
|
|
|
abstract insertAllBefore(el, nodes);
|
|
|
|
abstract insertAfter(el, node);
|
|
|
|
abstract setInnerHTML(el, value);
|
|
|
|
abstract getText(el): string;
|
|
|
|
abstract setText(el, value: string);
|
|
|
|
abstract getValue(el): string;
|
|
|
|
abstract setValue(el, value: string);
|
|
|
|
abstract getChecked(el): boolean;
|
|
|
|
abstract setChecked(el, value: boolean);
|
|
|
|
abstract createComment(text: string): any;
|
|
|
|
abstract createTemplate(html): HTMLElement;
|
|
|
|
abstract createElement(tagName, doc?): HTMLElement;
|
2015-10-27 13:16:27 -07:00
|
|
|
abstract createElementNS(ns: string, tagName: string, doc?): Element;
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract createTextNode(text: string, doc?): Text;
|
|
|
|
abstract createScriptTag(attrName: string, attrValue: string, doc?): HTMLElement;
|
|
|
|
abstract createStyleElement(css: string, doc?): HTMLStyleElement;
|
|
|
|
abstract createShadowRoot(el): any;
|
|
|
|
abstract getShadowRoot(el): any;
|
|
|
|
abstract getHost(el): any;
|
|
|
|
abstract getDistributedNodes(el): Node[];
|
|
|
|
abstract clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
|
|
|
abstract getElementsByClassName(element, name: string): HTMLElement[];
|
|
|
|
abstract getElementsByTagName(element, name: string): HTMLElement[];
|
|
|
|
abstract classList(element): any[];
|
2015-11-18 16:17:49 -08:00
|
|
|
abstract addClass(element, className: string);
|
|
|
|
abstract removeClass(element, className: string);
|
|
|
|
abstract hasClass(element, className: string): boolean;
|
2015-11-18 15:59:25 -08:00
|
|
|
abstract setStyle(element, styleName: string, styleValue: string);
|
|
|
|
abstract removeStyle(element, styleName: string);
|
|
|
|
abstract getStyle(element, styleName: string): string;
|
|
|
|
abstract hasStyle(element, styleName: string, styleValue?: string): boolean;
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract tagName(element): string;
|
|
|
|
abstract attributeMap(element): Map<string, string>;
|
|
|
|
abstract hasAttribute(element, attribute: string): boolean;
|
|
|
|
abstract getAttribute(element, attribute: string): string;
|
|
|
|
abstract setAttribute(element, name: string, value: string);
|
2015-10-27 13:16:27 -07:00
|
|
|
abstract setAttributeNS(element, ns: string, name: string, value: string);
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract removeAttribute(element, attribute: string);
|
|
|
|
abstract templateAwareRoot(el);
|
|
|
|
abstract createHtmlDocument(): HTMLDocument;
|
|
|
|
abstract defaultDoc(): HTMLDocument;
|
|
|
|
abstract getBoundingClientRect(el);
|
|
|
|
abstract getTitle(): string;
|
|
|
|
abstract setTitle(newTitle: string);
|
|
|
|
abstract elementMatches(n, selector: string): boolean;
|
|
|
|
abstract isTemplateElement(el: any): boolean;
|
|
|
|
abstract isTextNode(node): boolean;
|
|
|
|
abstract isCommentNode(node): boolean;
|
|
|
|
abstract isElementNode(node): boolean;
|
|
|
|
abstract hasShadowRoot(node): boolean;
|
|
|
|
abstract isShadowRoot(node): boolean;
|
|
|
|
abstract importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
|
|
|
abstract adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
|
|
|
abstract getHref(element): string;
|
|
|
|
abstract getEventKey(event): string;
|
|
|
|
abstract resolveAndSetHref(element, baseUrl: string, href: string);
|
|
|
|
abstract supportsDOMEvents(): boolean;
|
|
|
|
abstract supportsNativeShadowDOM(): boolean;
|
|
|
|
abstract getGlobalEventTarget(target: string): any;
|
|
|
|
abstract getHistory(): History;
|
|
|
|
abstract getLocation(): Location;
|
|
|
|
abstract getBaseHref(): string;
|
|
|
|
abstract resetBaseElement(): void;
|
|
|
|
abstract getUserAgent(): string;
|
|
|
|
abstract setData(element, name: string, value: string);
|
|
|
|
abstract getComputedStyle(element): any;
|
|
|
|
abstract getData(element, name: string): string;
|
|
|
|
abstract setGlobalVar(name: string, value: any);
|
|
|
|
abstract requestAnimationFrame(callback): number;
|
|
|
|
abstract cancelAnimationFrame(id);
|
|
|
|
abstract performanceNow(): number;
|
|
|
|
abstract getAnimationPrefix(): string;
|
|
|
|
abstract getTransitionEnd(): string;
|
|
|
|
abstract supportsAnimation(): boolean;
|
2015-05-12 11:19:47 -07:00
|
|
|
}
|