forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecial-properties.ts
More file actions
23 lines (18 loc) · 790 Bytes
/
special-properties.ts
File metadata and controls
23 lines (18 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import view = require("ui/core/view");
export type PropertySetter = (instance: view.View, propertyValue: string) => void;
var specialProperties: Map<string, PropertySetter> = new Map<string, PropertySetter>();
function specialPropertyKey(name: string) {
return name.toLowerCase();
}
export function registerSpecialProperty(name: string, setter: PropertySetter): void {
let propertyKey = specialPropertyKey(name);
if (specialProperties.has(propertyKey)) {
throw new Error(`Property for ${propertyKey} already registered`);
} else {
specialProperties.set(propertyKey, setter);
}
}
export function getSpecialPropertySetter(name: string): PropertySetter {
let propertyKey = specialPropertyKey(name);
return specialProperties.get(propertyKey);
}