forked from NativeScript/nativescript-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom-adapter.ts
More file actions
51 lines (43 loc) · 1.3 KB
/
dom-adapter.ts
File metadata and controls
51 lines (43 loc) · 1.3 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
import {ElementSchemaRegistry} from '@angular/compiler';
import {SanitizationService} from '@angular/core/src/security';
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
import {setRootDomAdapter} from '@angular/platform-browser/src/dom/dom_adapter';
import {Type} from '@angular/core/src/facade/lang';
import {rendererLog, rendererError} from "./trace";
export enum SecurityContext {
NONE,
HTML,
STYLE,
SCRIPT,
URL,
RESOURCE_URL,
}
export class NativeScriptElementSchemaRegistry extends ElementSchemaRegistry {
hasProperty(tagName: string, propName: string): boolean {
return true;
}
getMappedPropName(propName: string): string {
return propName;
}
securityContext(tagName: string, propName: string): any {
return SecurityContext.NONE;
}
}
export class NativeScriptSanitizationService extends SanitizationService {
sanitize(context: SecurityContext, value: string): string {
return value;
}
}
export class NativeScriptDomAdapter extends Parse5DomAdapter {
static makeCurrent() {
rendererLog("Setting DOM");
setRootDomAdapter(new NativeScriptDomAdapter());
}
getXHR(): Type {
return null;
}
hasProperty(element, name: string) {
//TODO: actually check if the property exists.
return true;
}
}