/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Type} from '@angular/core'; let _DOM: DomAdapter = null !; export function getDOM() { return _DOM; } export function setDOM(adapter: DomAdapter) { _DOM = adapter; } export function setRootDomAdapter(adapter: DomAdapter) { if (!_DOM) { _DOM = adapter; } } /* tslint:disable:requireParameterType */ /** * Provides DOM operations in an environment-agnostic way. * * @security Tread carefully! Interacting with the DOM directly is dangerous and * can introduce XSS risks. */ export abstract class DomAdapter { public resourceLoaderType: Type = null !; abstract hasProperty(element: any, name: string): boolean; abstract setProperty(el: Element, name: string, value: any): any; abstract getProperty(el: Element, name: string): any; abstract invoke(el: Element, methodName: string, args: any[]): any; abstract logError(error: any): any; abstract log(error: any): any; abstract logGroup(error: any): any; abstract logGroupEnd(): any; /** * Maps attribute names to their corresponding property names for cases * where attribute name doesn't match property name. */ get attrToPropMap(): {[key: string]: string} { return this._attrToPropMap; } set attrToPropMap(value: {[key: string]: string}) { this._attrToPropMap = value; } /** @internal */ // TODO(issue/24571): remove '!'. _attrToPropMap !: {[key: string]: string}; abstract contains(nodeA: any, nodeB: any): boolean; abstract parse(templateHtml: string): any; abstract querySelector(el: any, selector: string): any; abstract querySelectorAll(el: any, selector: string): any[]; abstract on(el: any, evt: any, listener: any): any; abstract onAndCancel(el: any, evt: any, listener: any): Function; abstract dispatchEvent(el: any, evt: any): any; abstract createMouseEvent(eventType: any): any; abstract createEvent(eventType: string): any; abstract preventDefault(evt: any): any; abstract isPrevented(evt: any): boolean; abstract getInnerHTML(el: any): string; /** Returns content if el is a