2015-05-19 18:05:02 -04:00
|
|
|
import {BaseException, isBlank} from 'angular2/src/facade/lang';
|
2015-05-12 14:19:47 -04:00
|
|
|
|
|
|
|
export var DOM: DomAdapter;
|
|
|
|
|
|
|
|
export function setRootDomAdapter(adapter: DomAdapter) {
|
2015-05-19 18:05:02 -04:00
|
|
|
if (isBlank(DOM)) {
|
|
|
|
DOM = adapter;
|
|
|
|
}
|
2015-05-12 14:19:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function _abstract() {
|
|
|
|
return new BaseException('This method is abstract');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides DOM operations in an environment-agnostic way.
|
|
|
|
*/
|
|
|
|
export class DomAdapter {
|
2015-06-18 18:44:44 -04:00
|
|
|
hasProperty(element, name: string): boolean { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
setProperty(el: Element, name: string, value: any) { throw _abstract(); }
|
|
|
|
getProperty(el: Element, name: string): any { throw _abstract(); }
|
|
|
|
invoke(el: Element, methodName: string, args: List<any>): any { throw _abstract(); }
|
2015-06-18 18:44:44 -04:00
|
|
|
|
2015-05-12 14:19:47 -04:00
|
|
|
logError(error) { throw _abstract(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps attribute names to their corresponding property names for cases
|
|
|
|
* where attribute name doesn't match property name.
|
|
|
|
*/
|
2015-05-20 12:48:15 -04:00
|
|
|
get attrToPropMap(): StringMap<string, string> { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
|
|
|
|
parse(templateHtml: string) { throw _abstract(); }
|
|
|
|
query(selector: string): any { throw _abstract(); }
|
2015-06-24 16:46:39 -04:00
|
|
|
querySelector(el, selector: string): HTMLElement { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
querySelectorAll(el, selector: string): List<any> { throw _abstract(); }
|
|
|
|
on(el, evt, listener) { throw _abstract(); }
|
|
|
|
onAndCancel(el, evt, listener): Function { throw _abstract(); }
|
|
|
|
dispatchEvent(el, evt) { throw _abstract(); }
|
|
|
|
createMouseEvent(eventType): any { throw _abstract(); }
|
|
|
|
createEvent(eventType: string): any { throw _abstract(); }
|
2015-05-21 05:32:29 -04:00
|
|
|
preventDefault(evt) { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
getInnerHTML(el): string { throw _abstract(); }
|
|
|
|
getOuterHTML(el): string { throw _abstract(); }
|
|
|
|
nodeName(node): string { throw _abstract(); }
|
|
|
|
nodeValue(node): string { throw _abstract(); }
|
|
|
|
type(node): string { throw _abstract(); }
|
|
|
|
content(node): any { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
firstChild(el): Node { throw _abstract(); }
|
|
|
|
nextSibling(el): Node { throw _abstract(); }
|
|
|
|
parentElement(el): Node { throw _abstract(); }
|
|
|
|
childNodes(el): List<Node> { throw _abstract(); }
|
|
|
|
childNodesAsList(el): List<Node> { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
clearNodes(el) { throw _abstract(); }
|
|
|
|
appendChild(el, node) { throw _abstract(); }
|
|
|
|
removeChild(el, node) { throw _abstract(); }
|
|
|
|
replaceChild(el, newNode, oldNode) { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
remove(el): Node { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
insertBefore(el, node) { throw _abstract(); }
|
|
|
|
insertAllBefore(el, nodes) { throw _abstract(); }
|
|
|
|
insertAfter(el, node) { throw _abstract(); }
|
|
|
|
setInnerHTML(el, value) { throw _abstract(); }
|
2015-06-26 14:10:52 -04:00
|
|
|
getText(el): string { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
setText(el, value: string) { throw _abstract(); }
|
2015-06-26 14:10:52 -04:00
|
|
|
getValue(el): string { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
setValue(el, value: string) { throw _abstract(); }
|
2015-06-26 14:10:52 -04:00
|
|
|
getChecked(el): boolean { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
setChecked(el, value: boolean) { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
createTemplate(html): HTMLElement { throw _abstract(); }
|
|
|
|
createElement(tagName, doc = null): HTMLElement { throw _abstract(); }
|
|
|
|
createTextNode(text: string, doc = null): Text { throw _abstract(); }
|
|
|
|
createScriptTag(attrName: string, attrValue: string, doc = null): HTMLElement {
|
2015-06-26 14:10:52 -04:00
|
|
|
throw _abstract();
|
|
|
|
}
|
2015-06-30 20:38:33 -04:00
|
|
|
createStyleElement(css: string, doc = null): HTMLStyleElement { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
createShadowRoot(el): any { throw _abstract(); }
|
|
|
|
getShadowRoot(el): any { throw _abstract(); }
|
|
|
|
getHost(el): any { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
getDistributedNodes(el): List<Node> { throw _abstract(); }
|
2015-06-24 16:46:39 -04:00
|
|
|
clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
getElementsByClassName(element, name: string): List<HTMLElement> { throw _abstract(); }
|
|
|
|
getElementsByTagName(element, name: string): List<HTMLElement> { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
classList(element): List<any> { throw _abstract(); }
|
|
|
|
addClass(element, classname: string) { throw _abstract(); }
|
|
|
|
removeClass(element, classname: string) { throw _abstract(); }
|
2015-06-26 14:10:52 -04:00
|
|
|
hasClass(element, classname: string): boolean { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
setStyle(element, stylename: string, stylevalue: string) { throw _abstract(); }
|
|
|
|
removeStyle(element, stylename: string) { throw _abstract(); }
|
2015-06-26 14:10:52 -04:00
|
|
|
getStyle(element, stylename: string): string { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
tagName(element): string { throw _abstract(); }
|
2015-05-18 14:57:20 -04:00
|
|
|
attributeMap(element): Map<string, string> { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
hasAttribute(element, attribute: string): boolean { throw _abstract(); }
|
|
|
|
getAttribute(element, attribute: string): string { throw _abstract(); }
|
|
|
|
setAttribute(element, name: string, value: string) { throw _abstract(); }
|
|
|
|
removeAttribute(element, attribute: string) { throw _abstract(); }
|
|
|
|
templateAwareRoot(el) { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
createHtmlDocument(): HTMLDocument { throw _abstract(); }
|
|
|
|
defaultDoc(): HTMLDocument { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
getBoundingClientRect(el) { throw _abstract(); }
|
2015-05-18 14:57:20 -04:00
|
|
|
getTitle(): string { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
setTitle(newTitle: string) { throw _abstract(); }
|
|
|
|
elementMatches(n, selector: string): boolean { throw _abstract(); }
|
|
|
|
isTemplateElement(el: any): boolean { throw _abstract(); }
|
|
|
|
isTextNode(node): boolean { throw _abstract(); }
|
|
|
|
isCommentNode(node): boolean { throw _abstract(); }
|
|
|
|
isElementNode(node): boolean { throw _abstract(); }
|
|
|
|
hasShadowRoot(node): boolean { throw _abstract(); }
|
|
|
|
isShadowRoot(node): boolean { throw _abstract(); }
|
2015-06-24 16:46:39 -04:00
|
|
|
importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
isPageRule(rule): boolean { throw _abstract(); }
|
|
|
|
isStyleRule(rule): boolean { throw _abstract(); }
|
|
|
|
isMediaRule(rule): boolean { throw _abstract(); }
|
|
|
|
isKeyframesRule(rule): boolean { throw _abstract(); }
|
|
|
|
getHref(element): string { throw _abstract(); }
|
|
|
|
getEventKey(event): string { throw _abstract(); }
|
|
|
|
resolveAndSetHref(element, baseUrl: string, href: string) { throw _abstract(); }
|
|
|
|
cssToRules(css: string): List<any> { throw _abstract(); }
|
|
|
|
supportsDOMEvents(): boolean { throw _abstract(); }
|
|
|
|
supportsNativeShadowDOM(): boolean { throw _abstract(); }
|
2015-05-29 17:58:41 -04:00
|
|
|
getGlobalEventTarget(target: string): any { throw _abstract(); }
|
2015-06-30 20:38:33 -04:00
|
|
|
getHistory(): History { throw _abstract(); }
|
|
|
|
getLocation(): Location { throw _abstract(); }
|
2015-05-29 17:58:41 -04:00
|
|
|
getBaseHref(): string { throw _abstract(); }
|
2015-05-26 12:45:15 -04:00
|
|
|
getUserAgent(): string { throw _abstract(); }
|
2015-05-28 17:56:40 -04:00
|
|
|
setData(element, name: string, value: string) { throw _abstract(); }
|
|
|
|
getData(element, name: string): string { throw _abstract(); }
|
|
|
|
setGlobalVar(name: string, value: any) { throw _abstract(); }
|
2015-05-12 14:19:47 -04:00
|
|
|
}
|