##// END OF EJS Templates
minor code cleanups
cin -
r93:d99e2014cea4 default
parent child
Show More
@@ -6,14 +6,14 plugins {
6 typescript {
6 typescript {
7 compilerOptions {
7 compilerOptions {
8 lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"]
8 lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"]
9 //listFiles = true
9 // listFiles = true
10 declaration = true
10 declaration = true
11 strict = true
11 strict = true
12 types = []
12 types = []
13 module = "amd"
13 module = "amd"
14 it.target = "es5"
14 it.target = "es5"
15 experimentalDecorators = true
15 experimentalDecorators = true
16 noUnusedLocals = true
16 noUnusedLocals = false
17 jsx = "react"
17 jsx = "react"
18 jsxFactory = "createElement"
18 jsxFactory = "createElement"
19 moduleResolution = "node"
19 moduleResolution = "node"
@@ -114,6 +114,6 export const on = <E extends string>(...
114 key: K,
114 key: K,
115 _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void>
115 _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void>
116 ): any => {
116 ): any => {
117 const handlers = eventNames.map(eventName => ({ eventName, handlerMethod: key }))
117 const handlers = eventNames.map(eventName => ({ eventName, handlerMethod: key }));
118 target._eventHandlers = target._eventHandlers ? target._eventHandlers.concat(handlers) : handlers;
118 target._eventHandlers = target._eventHandlers ? target._eventHandlers.concat(handlers) : handlers;
119 };
119 };
@@ -23,8 +23,7 export class HtmlRendition extends Rendi
23 _create(attrs: object, children: any[]) {
23 _create(attrs: object, children: any[]) {
24 this._element = dom.create(this.elementType, attrs);
24 this._element = dom.create(this.elementType, attrs);
25
25
26 if (children)
26 children.forEach(v => this._addChild(v));
27 children.forEach(v => this._addChild(v));
28 }
27 }
29
28
30 _getDomNode() {
29 _getDomNode() {
@@ -29,6 +29,7 export abstract class RenditionBase<TNod
29 }
29 }
30 }
30 }
31
31
32 /** Renders DOM element for different types of the argument. */
32 protected getItemDom(v: any) {
33 protected getItemDom(v: any) {
33 const tv = typeof v;
34 const tv = typeof v;
34
35
@@ -39,7 +40,7 export abstract class RenditionBase<TNod
39 // nodes are kept as is
40 // nodes are kept as is
40 return v;
41 return v;
41 } else if (isRendition(v)) {
42 } else if (isRendition(v)) {
42 // renditions as instantinated
43 // renditions are instantiated
43 return v.getDomNode();
44 return v.getDomNode();
44 } else if (isWidget(v)) {
45 } else if (isWidget(v)) {
45 // widgets are converted to it's markup
46 // widgets are converted to it's markup
@@ -62,9 +63,9 export abstract class RenditionBase<TNod
62 }
63 }
63 }
64 }
64
65
65 /** @deprecated will be removed in 1.0.0, use getDomNode() */
66 /** Is rendition was instantiated to the DOM node */
66 getDomElement() {
67 isCreated() {
67 return this.getDomNode();
68 return this._created;
68 }
69 }
69
70
70 /** Creates DOM node if not created. No additional actions are taken. */
71 /** Creates DOM node if not created. No additional actions are taken. */
@@ -107,12 +107,14 export function destroy(target: Node | I
107 } else if (isDestroyable(target)) {
107 } else if (isDestroyable(target)) {
108 target.destroy();
108 target.destroy();
109 } else if (isNode(target)) {
109 } else if (isNode(target)) {
110 const w = isElementNode(target) ? registry.byNode(target) : undefined;
110 if (isElementNode(target)) {
111 if (w) {
111 const w = registry.byNode(target);
112 w.destroyRecursive();
112 if (w) {
113 } else {
113 w.destroyRecursive();
114 registry.findWidgets(target).forEach(destroy);
114 } else {
115 dom.destroy(target);
115 registry.findWidgets(target).forEach(destroy);
116 dom.destroy(target);
117 }
116 }
118 }
117 }
119 }
118 }
120 }
@@ -134,12 +136,14 export function emptyNode(target: Node)
134 */
136 */
135 export function startupWidgets(target: Node | _WidgetBase, skipNode?: Node) {
137 export function startupWidgets(target: Node | _WidgetBase, skipNode?: Node) {
136 if (isNode(target)) {
138 if (isNode(target)) {
137 const w = isElementNode(target) ? registry.byNode(target) : undefined;
139 if (isElementNode(target)) {
138 if (w) {
140 const w = registry.byNode(target);
139 if (w.startup)
141 if (w) {
140 w.startup();
142 if (w.startup)
141 } else {
143 w.startup();
142 registry.findWidgets(target, skipNode).forEach(x => x.startup());
144 } else {
145 registry.findWidgets(target, skipNode).forEach(x => x.startup());
146 }
143 }
147 }
144 } else {
148 } else {
145 if (target.startup)
149 if (target.startup)
@@ -60,7 +60,7 export class MyWidget extends djbase(Djx
60 }
60 }
61
61
62 @on("count-inc")
62 @on("count-inc")
63 _onCounterInc(evt: Event & { detail: number; x?: number; }) {
63 private _onCounterInc(evt: Event & { detail: number; x?: number; }) {
64 }
64 }
65
65
66 @on("click", "keydown")
66 @on("click", "keydown")
@@ -1,6 +1,7
1 {
1 {
2 "extends": "../tsconfig",
2 "extends": "../tsconfig",
3 "compilerOptions": {
3 "compilerOptions": {
4 "noUnusedLocals": false,
4 //"rootDir": "ts",
5 //"rootDir": "ts",
5 "rootDirs": [
6 "rootDirs": [
6 "ts",
7 "ts",
General Comments 0
You need to be logged in to leave comments. Login now