forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom_adapter.ts
More file actions
58 lines (46 loc) · 1.63 KB
/
dom_adapter.ts
File metadata and controls
58 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @license
* Copyright Google LLC 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.dev/license
*/
let _DOM: DomAdapter = null!;
export function getDOM(): DomAdapter {
return _DOM;
}
export function setRootDomAdapter(adapter: DomAdapter) {
_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 {
// Needs Domino-friendly test utility
abstract dispatchEvent(el: any, evt: any): any;
abstract readonly supportsDOMEvents: boolean;
// Used by Meta
abstract remove(el: any): void;
abstract createElement(tagName: any, doc?: any): HTMLElement;
abstract createHtmlDocument(): Document;
abstract getDefaultDocument(): Document;
// Used by By.css
abstract isElementNode(node: any): boolean;
// Used by Testability
abstract isShadowRoot(node: any): boolean;
// Used by KeyEventsPlugin
abstract onAndCancel(el: any, evt: any, listener: any): Function;
// Used by PlatformLocation and ServerEventManagerPlugin
abstract getGlobalEventTarget(doc: Document, target: string): any;
// Used by PlatformLocation
abstract getBaseHref(doc: Document): string | null;
abstract resetBaseElement(): void;
// TODO: remove dependency in DefaultValueAccessor
abstract getUserAgent(): string;
// Used in the legacy @angular/http package which has some usage in g3.
abstract getCookie(name: string): string | null;
}