2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2017-03-24 12:59:41 -04:00
|
|
|
let _DOM: DomAdapter = null !;
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2019-08-22 22:16:25 -04:00
|
|
|
export function getDOM(): DomAdapter {
|
2016-04-28 20:50:03 -04:00
|
|
|
return _DOM;
|
|
|
|
}
|
|
|
|
|
2016-05-02 01:50:37 -04:00
|
|
|
export function setDOM(adapter: DomAdapter) {
|
2016-04-28 20:50:03 -04:00
|
|
|
_DOM = adapter;
|
|
|
|
}
|
2015-05-12 14:19:47 -04:00
|
|
|
|
|
|
|
export function setRootDomAdapter(adapter: DomAdapter) {
|
2016-09-30 12:26:53 -04:00
|
|
|
if (!_DOM) {
|
2016-04-28 20:50:03 -04:00
|
|
|
_DOM = adapter;
|
2015-05-19 18:05:02 -04:00
|
|
|
}
|
2015-05-12 14:19:47 -04:00
|
|
|
}
|
|
|
|
|
2015-07-07 23:03:00 -04:00
|
|
|
/* tslint:disable:requireParameterType */
|
2015-05-12 14:19:47 -04:00
|
|
|
/**
|
|
|
|
* Provides DOM operations in an environment-agnostic way.
|
2016-08-17 16:42:18 -04:00
|
|
|
*
|
|
|
|
* @security Tread carefully! Interacting with the DOM directly is dangerous and
|
|
|
|
* can introduce XSS risks.
|
2015-05-12 14:19:47 -04:00
|
|
|
*/
|
2015-09-25 17:48:17 -04:00
|
|
|
export abstract class DomAdapter {
|
2019-08-27 19:39:33 -04:00
|
|
|
// Needs Domino-friendly test utility
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract getProperty(el: Element, name: string): any;
|
2019-08-27 19:39:33 -04:00
|
|
|
abstract dispatchEvent(el: any, evt: any): any;
|
2015-06-18 18:44:44 -04:00
|
|
|
|
2019-08-27 19:39:33 -04:00
|
|
|
// Used by router
|
2017-02-15 00:03:18 -05:00
|
|
|
abstract log(error: any): any;
|
|
|
|
abstract logGroup(error: any): any;
|
|
|
|
abstract logGroupEnd(): any;
|
2015-05-12 14:19:47 -04:00
|
|
|
|
2019-08-23 16:28:33 -04:00
|
|
|
// Used by Meta
|
|
|
|
abstract remove(el: any): Node;
|
2017-02-15 00:03:18 -05:00
|
|
|
abstract createElement(tagName: any, doc?: any): HTMLElement;
|
2019-08-30 00:24:33 -04:00
|
|
|
abstract createHtmlDocument(): HTMLDocument;
|
|
|
|
abstract getDefaultDocument(): Document;
|
|
|
|
|
2019-08-22 22:48:08 -04:00
|
|
|
// Used by By.css
|
2017-02-15 00:03:18 -05:00
|
|
|
abstract isElementNode(node: any): boolean;
|
2019-08-22 21:26:01 -04:00
|
|
|
|
|
|
|
// Used by Testability
|
2017-02-15 00:03:18 -05:00
|
|
|
abstract isShadowRoot(node: any): boolean;
|
2019-08-22 21:26:01 -04:00
|
|
|
|
|
|
|
// Used by KeyEventsPlugin
|
2019-08-27 19:21:39 -04:00
|
|
|
abstract onAndCancel(el: any, evt: any, listener: any): Function;
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract supportsDOMEvents(): boolean;
|
2019-08-22 21:26:01 -04:00
|
|
|
|
|
|
|
// Used by PlatformLocation and ServerEventManagerPlugin
|
2017-02-14 19:14:40 -05:00
|
|
|
abstract getGlobalEventTarget(doc: Document, target: string): any;
|
2019-08-22 21:26:01 -04:00
|
|
|
|
|
|
|
// Used by PlatformLocation
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract getHistory(): History;
|
2019-08-22 22:16:25 -04:00
|
|
|
abstract getLocation():
|
|
|
|
any; /** This is the ambient Location definition, NOT Location from @angular/common. */
|
2017-03-24 12:59:41 -04:00
|
|
|
abstract getBaseHref(doc: Document): string|null;
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract resetBaseElement(): void;
|
2019-08-22 20:09:07 -04:00
|
|
|
|
|
|
|
// TODO: remove dependency in DefaultValueAccessor
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract getUserAgent(): string;
|
2019-08-22 20:49:43 -04:00
|
|
|
|
|
|
|
// Used by AngularProfiler
|
2015-09-25 17:48:17 -04:00
|
|
|
abstract performanceNow(): number;
|
2016-05-27 23:15:40 -04:00
|
|
|
|
2019-08-22 19:14:18 -04:00
|
|
|
// Used by CookieXSRFStrategy
|
2016-05-27 23:15:40 -04:00
|
|
|
abstract supportsCookies(): boolean;
|
2017-03-24 12:59:41 -04:00
|
|
|
abstract getCookie(name: string): string|null;
|
2015-05-12 14:19:47 -04:00
|
|
|
}
|