vasille 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -28
- package/cdn/es2015.js +148 -854
- package/cdn/es5.js +820 -1091
- package/flow-typed/vasille.js +51 -96
- package/lib/binding/attribute.js +1 -1
- package/lib/binding/binding.js +5 -5
- package/lib/binding/class.js +2 -2
- package/lib/binding/style.js +1 -1
- package/lib/core/core.js +15 -15
- package/lib/core/destroyable.js +2 -2
- package/lib/core/ivalue.js +4 -4
- package/lib/index.js +2 -3
- package/lib/models/array-model.js +6 -9
- package/lib/models/object-model.js +3 -17
- package/lib/node/app.js +3 -3
- package/lib/node/node.js +45 -42
- package/lib/node/watch.js +1 -1
- package/lib/value/expression.js +13 -13
- package/lib/value/mirror.js +15 -15
- package/lib/value/pointer.js +5 -5
- package/lib/value/reference.js +18 -18
- package/lib/views/base-view.js +1 -1
- package/lib/views/object-view.js +1 -1
- package/lib/views/repeat-node.js +4 -4
- package/lib-node/binding/attribute.js +35 -0
- package/lib-node/binding/binding.js +33 -0
- package/lib-node/binding/class.js +48 -0
- package/lib-node/binding/style.js +27 -0
- package/lib-node/core/core.js +243 -0
- package/lib-node/core/destroyable.js +49 -0
- package/lib-node/core/errors.js +23 -0
- package/lib-node/core/ivalue.js +63 -0
- package/lib-node/functional/options.js +2 -0
- package/lib-node/index.js +49 -0
- package/lib-node/models/array-model.js +218 -0
- package/lib-node/models/listener.js +134 -0
- package/lib-node/models/map-model.js +70 -0
- package/lib-node/models/model.js +2 -0
- package/lib-node/models/object-model.js +82 -0
- package/lib-node/models/set-model.js +66 -0
- package/lib-node/node/app.js +54 -0
- package/lib-node/node/node.js +885 -0
- package/lib-node/node/watch.js +23 -0
- package/lib-node/spec/html.js +2 -0
- package/lib-node/spec/react.js +2 -0
- package/lib-node/spec/svg.js +2 -0
- package/lib-node/value/expression.js +90 -0
- package/lib-node/value/mirror.js +60 -0
- package/lib-node/value/pointer.js +30 -0
- package/lib-node/value/reference.js +55 -0
- package/lib-node/views/array-view.js +21 -0
- package/lib-node/views/base-view.js +43 -0
- package/lib-node/views/map-view.js +18 -0
- package/lib-node/views/object-view.js +20 -0
- package/lib-node/views/repeat-node.js +71 -0
- package/lib-node/views/set-view.js +19 -0
- package/package.json +21 -17
- package/types/binding/binding.d.ts +1 -1
- package/types/core/core.d.ts +6 -6
- package/types/core/destroyable.d.ts +2 -2
- package/types/core/ivalue.d.ts +4 -4
- package/types/functional/options.d.ts +2 -2
- package/types/index.d.ts +3 -4
- package/types/models/array-model.d.ts +1 -1
- package/types/models/object-model.d.ts +1 -1
- package/types/node/node.d.ts +16 -15
- package/types/node/watch.d.ts +2 -2
- package/types/value/expression.d.ts +5 -5
- package/types/value/mirror.d.ts +6 -6
- package/types/value/pointer.d.ts +1 -1
- package/types/value/reference.d.ts +7 -7
- package/types/views/repeat-node.d.ts +3 -3
- package/lib/core/executor.js +0 -154
- package/lib/core/signal.js +0 -50
- package/lib/core/slot.js +0 -47
- package/lib/functional/components.js +0 -17
- package/lib/functional/merge.js +0 -41
- package/lib/functional/models.js +0 -26
- package/lib/functional/reactivity.js +0 -33
- package/lib/functional/stack.js +0 -127
- package/lib/node/interceptor.js +0 -83
- package/lib/v/index.js +0 -23
- package/lib/views/repeater.js +0 -63
- package/types/functional/components.d.ts +0 -4
- package/types/functional/merge.d.ts +0 -1
- package/types/functional/models.d.ts +0 -10
- package/types/functional/reactivity.d.ts +0 -11
- package/types/functional/stack.d.ts +0 -24
- package/types/v/index.d.ts +0 -32
package/lib/node/app.js
CHANGED
|
@@ -11,7 +11,7 @@ export class AppNode extends INode {
|
|
|
11
11
|
constructor(input) {
|
|
12
12
|
super(input);
|
|
13
13
|
this.debugUi = input.debugUi || false;
|
|
14
|
-
this
|
|
14
|
+
this.$seal();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -30,7 +30,7 @@ export class App extends AppNode {
|
|
|
30
30
|
this.$.node = node;
|
|
31
31
|
this.preinit(this, this);
|
|
32
32
|
this.init();
|
|
33
|
-
this
|
|
33
|
+
this.$seal();
|
|
34
34
|
}
|
|
35
35
|
appendNode(node) {
|
|
36
36
|
this.$.node.appendChild(node);
|
|
@@ -40,7 +40,7 @@ export class Portal extends AppNode {
|
|
|
40
40
|
constructor(input) {
|
|
41
41
|
super(input);
|
|
42
42
|
this.$.node = input.node;
|
|
43
|
-
this
|
|
43
|
+
this.$seal();
|
|
44
44
|
}
|
|
45
45
|
appendNode(node) {
|
|
46
46
|
this.$.node.appendChild(node);
|
package/lib/node/node.js
CHANGED
|
@@ -14,7 +14,7 @@ import { internalError, userError } from "../core/errors";
|
|
|
14
14
|
export class FragmentPrivate extends ReactivePrivate {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
|
-
this
|
|
17
|
+
this.$seal();
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Pre-initializes the base of a fragment
|
|
@@ -28,10 +28,10 @@ export class FragmentPrivate extends ReactivePrivate {
|
|
|
28
28
|
/**
|
|
29
29
|
* Unlinks all bindings
|
|
30
30
|
*/
|
|
31
|
-
destroy() {
|
|
31
|
+
$destroy() {
|
|
32
32
|
this.next = null;
|
|
33
33
|
this.prev = null;
|
|
34
|
-
super
|
|
34
|
+
super.$destroy();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -70,11 +70,11 @@ export class Fragment extends Reactive {
|
|
|
70
70
|
$.preinit(app, parent);
|
|
71
71
|
}
|
|
72
72
|
init() {
|
|
73
|
-
super.init();
|
|
73
|
+
const ret = super.init();
|
|
74
74
|
this.ready();
|
|
75
|
+
return ret;
|
|
75
76
|
}
|
|
76
77
|
compose(input) {
|
|
77
|
-
super.compose(input);
|
|
78
78
|
input.slot && input.slot(this);
|
|
79
79
|
}
|
|
80
80
|
/** To be overloaded: ready event handler */
|
|
@@ -182,7 +182,7 @@ export class Fragment extends Reactive {
|
|
|
182
182
|
node.preinit($.app, this);
|
|
183
183
|
node.input.slot = callback || node.input.slot;
|
|
184
184
|
this.pushNode(node);
|
|
185
|
-
node.init();
|
|
185
|
+
return node.init();
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
188
|
* Defines an if node
|
|
@@ -254,14 +254,14 @@ export class Fragment extends Reactive {
|
|
|
254
254
|
$.prev.$.next = $.next;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
destroy() {
|
|
258
|
-
this.children.forEach(child => child
|
|
257
|
+
$destroy() {
|
|
258
|
+
this.children.forEach(child => child.$destroy());
|
|
259
259
|
this.children.clear();
|
|
260
260
|
this.lastChild = null;
|
|
261
261
|
if (this.$.parent.lastChild === this) {
|
|
262
262
|
this.$.parent.lastChild = this.$.prev;
|
|
263
263
|
}
|
|
264
|
-
super
|
|
264
|
+
super.$destroy();
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
const trueIValue = new Reference(true);
|
|
@@ -273,7 +273,7 @@ const trueIValue = new Reference(true);
|
|
|
273
273
|
export class TextNodePrivate extends FragmentPrivate {
|
|
274
274
|
constructor() {
|
|
275
275
|
super();
|
|
276
|
-
this
|
|
276
|
+
this.$seal();
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
279
|
* Pre-initializes a text node
|
|
@@ -293,8 +293,8 @@ export class TextNodePrivate extends FragmentPrivate {
|
|
|
293
293
|
/**
|
|
294
294
|
* Clear node data
|
|
295
295
|
*/
|
|
296
|
-
destroy() {
|
|
297
|
-
super
|
|
296
|
+
$destroy() {
|
|
297
|
+
super.$destroy();
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
@@ -305,7 +305,7 @@ export class TextNodePrivate extends FragmentPrivate {
|
|
|
305
305
|
export class TextNode extends Fragment {
|
|
306
306
|
constructor($ = new TextNodePrivate()) {
|
|
307
307
|
super({}, $);
|
|
308
|
-
this
|
|
308
|
+
this.$seal();
|
|
309
309
|
}
|
|
310
310
|
preinit(app, parent, text) {
|
|
311
311
|
const $ = this.$;
|
|
@@ -318,10 +318,10 @@ export class TextNode extends Fragment {
|
|
|
318
318
|
findFirstChild() {
|
|
319
319
|
return this.$.node;
|
|
320
320
|
}
|
|
321
|
-
destroy() {
|
|
321
|
+
$destroy() {
|
|
322
322
|
this.$.node.remove();
|
|
323
|
-
this
|
|
324
|
-
super
|
|
323
|
+
this.$.$destroy();
|
|
324
|
+
super.$destroy();
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
/**
|
|
@@ -337,10 +337,10 @@ export class INodePrivate extends FragmentPrivate {
|
|
|
337
337
|
* @type {boolean}
|
|
338
338
|
*/
|
|
339
339
|
this.unmounted = false;
|
|
340
|
-
this
|
|
340
|
+
this.$seal();
|
|
341
341
|
}
|
|
342
|
-
destroy() {
|
|
343
|
-
super
|
|
342
|
+
$destroy() {
|
|
343
|
+
super.$destroy();
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
/**
|
|
@@ -356,7 +356,7 @@ export class INode extends Fragment {
|
|
|
356
356
|
*/
|
|
357
357
|
constructor(input, $) {
|
|
358
358
|
super(input, $ || new INodePrivate);
|
|
359
|
-
this
|
|
359
|
+
this.$seal();
|
|
360
360
|
}
|
|
361
361
|
/**
|
|
362
362
|
* Get the bound node
|
|
@@ -599,7 +599,7 @@ export class INode extends Fragment {
|
|
|
599
599
|
export class Tag extends INode {
|
|
600
600
|
constructor(input) {
|
|
601
601
|
super(input);
|
|
602
|
-
this
|
|
602
|
+
this.$seal();
|
|
603
603
|
}
|
|
604
604
|
preinit(app, parent, tagName) {
|
|
605
605
|
if (!tagName || typeof tagName !== "string") {
|
|
@@ -652,9 +652,9 @@ export class Tag extends INode {
|
|
|
652
652
|
/**
|
|
653
653
|
* Runs GC
|
|
654
654
|
*/
|
|
655
|
-
destroy() {
|
|
655
|
+
$destroy() {
|
|
656
656
|
this.node.remove();
|
|
657
|
-
super
|
|
657
|
+
super.$destroy();
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
/**
|
|
@@ -677,8 +677,11 @@ export class Extension extends INode {
|
|
|
677
677
|
throw userError("A extension node can be encapsulated only in a tag/extension/component", "virtual-dom");
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
|
|
681
|
-
|
|
680
|
+
extend(options) {
|
|
681
|
+
this.applyOptions(options);
|
|
682
|
+
}
|
|
683
|
+
$destroy() {
|
|
684
|
+
super.$destroy();
|
|
682
685
|
}
|
|
683
686
|
}
|
|
684
687
|
/**
|
|
@@ -723,18 +726,18 @@ export class SwitchedNodePrivate extends FragmentPrivate {
|
|
|
723
726
|
* @type {Array<{cond : IValue<boolean>, cb : function(Fragment)}>}
|
|
724
727
|
*/
|
|
725
728
|
this.cases = [];
|
|
726
|
-
this
|
|
729
|
+
this.$seal();
|
|
727
730
|
}
|
|
728
731
|
/**
|
|
729
732
|
* Runs GC
|
|
730
733
|
*/
|
|
731
|
-
destroy() {
|
|
734
|
+
$destroy() {
|
|
732
735
|
this.cases.forEach(c => {
|
|
733
736
|
delete c.cond;
|
|
734
737
|
delete c.cb;
|
|
735
738
|
});
|
|
736
739
|
this.cases.splice(0);
|
|
737
|
-
super
|
|
740
|
+
super.$destroy();
|
|
738
741
|
}
|
|
739
742
|
}
|
|
740
743
|
/**
|
|
@@ -758,7 +761,7 @@ export class SwitchedNode extends Fragment {
|
|
|
758
761
|
return;
|
|
759
762
|
}
|
|
760
763
|
if (this.lastChild) {
|
|
761
|
-
this.lastChild
|
|
764
|
+
this.lastChild.$destroy();
|
|
762
765
|
this.children.clear();
|
|
763
766
|
this.lastChild = null;
|
|
764
767
|
}
|
|
@@ -770,11 +773,11 @@ export class SwitchedNode extends Fragment {
|
|
|
770
773
|
$.index = -1;
|
|
771
774
|
}
|
|
772
775
|
};
|
|
773
|
-
this
|
|
776
|
+
this.$seal();
|
|
774
777
|
}
|
|
775
778
|
addCase(case_) {
|
|
776
779
|
this.$.cases.push(case_);
|
|
777
|
-
case_.cond
|
|
780
|
+
case_.cond.$on(this.$.sync);
|
|
778
781
|
this.$.sync();
|
|
779
782
|
}
|
|
780
783
|
/**
|
|
@@ -792,16 +795,16 @@ export class SwitchedNode extends Fragment {
|
|
|
792
795
|
ready() {
|
|
793
796
|
const $ = this.$;
|
|
794
797
|
$.cases.forEach(c => {
|
|
795
|
-
c.cond
|
|
798
|
+
c.cond.$on($.sync);
|
|
796
799
|
});
|
|
797
800
|
$.sync();
|
|
798
801
|
}
|
|
799
|
-
destroy() {
|
|
802
|
+
$destroy() {
|
|
800
803
|
const $ = this.$;
|
|
801
804
|
$.cases.forEach(c => {
|
|
802
|
-
c.cond
|
|
805
|
+
c.cond.$off($.sync);
|
|
803
806
|
});
|
|
804
|
-
super
|
|
807
|
+
super.$destroy();
|
|
805
808
|
}
|
|
806
809
|
}
|
|
807
810
|
/**
|
|
@@ -810,7 +813,7 @@ export class SwitchedNode extends Fragment {
|
|
|
810
813
|
export class DebugPrivate extends FragmentPrivate {
|
|
811
814
|
constructor() {
|
|
812
815
|
super();
|
|
813
|
-
this
|
|
816
|
+
this.$seal();
|
|
814
817
|
}
|
|
815
818
|
/**
|
|
816
819
|
* Pre-initializes a text node
|
|
@@ -829,9 +832,9 @@ export class DebugPrivate extends FragmentPrivate {
|
|
|
829
832
|
/**
|
|
830
833
|
* Clear node data
|
|
831
834
|
*/
|
|
832
|
-
destroy() {
|
|
835
|
+
$destroy() {
|
|
833
836
|
this.node.remove();
|
|
834
|
-
super
|
|
837
|
+
super.$destroy();
|
|
835
838
|
}
|
|
836
839
|
}
|
|
837
840
|
/**
|
|
@@ -847,7 +850,7 @@ export class DebugNode extends Fragment {
|
|
|
847
850
|
* @type {DebugNode}
|
|
848
851
|
*/
|
|
849
852
|
this.$ = new DebugPrivate();
|
|
850
|
-
this
|
|
853
|
+
this.$seal();
|
|
851
854
|
}
|
|
852
855
|
preinit(app, parent, text) {
|
|
853
856
|
const $ = this.$;
|
|
@@ -859,8 +862,8 @@ export class DebugNode extends Fragment {
|
|
|
859
862
|
/**
|
|
860
863
|
* Runs garbage collector
|
|
861
864
|
*/
|
|
862
|
-
destroy() {
|
|
863
|
-
this
|
|
864
|
-
super
|
|
865
|
+
$destroy() {
|
|
866
|
+
this.$.$destroy();
|
|
867
|
+
super.$destroy();
|
|
865
868
|
}
|
|
866
869
|
}
|
package/lib/node/watch.js
CHANGED
package/lib/value/expression.js
CHANGED
|
@@ -35,12 +35,12 @@ export class Expression extends IValue {
|
|
|
35
35
|
this.values = values;
|
|
36
36
|
this.func = handler;
|
|
37
37
|
if (link) {
|
|
38
|
-
this
|
|
38
|
+
this.$enable();
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
handler();
|
|
42
42
|
}
|
|
43
|
-
this
|
|
43
|
+
this.$seal();
|
|
44
44
|
}
|
|
45
45
|
get $() {
|
|
46
46
|
return this.sync.$;
|
|
@@ -48,18 +48,18 @@ export class Expression extends IValue {
|
|
|
48
48
|
set $(value) {
|
|
49
49
|
this.sync.$ = value;
|
|
50
50
|
}
|
|
51
|
-
on(handler) {
|
|
52
|
-
this.sync
|
|
51
|
+
$on(handler) {
|
|
52
|
+
this.sync.$on(handler);
|
|
53
53
|
return this;
|
|
54
54
|
}
|
|
55
|
-
off(handler) {
|
|
56
|
-
this.sync
|
|
55
|
+
$off(handler) {
|
|
56
|
+
this.sync.$off(handler);
|
|
57
57
|
return this;
|
|
58
58
|
}
|
|
59
|
-
enable() {
|
|
59
|
+
$enable() {
|
|
60
60
|
if (!this.isEnabled) {
|
|
61
61
|
for (let i = 0; i < this.values.length; i++) {
|
|
62
|
-
this.values[i]
|
|
62
|
+
this.values[i].$on(this.linkedFunc[i]);
|
|
63
63
|
this.valuesCache[i] = this.values[i].$;
|
|
64
64
|
}
|
|
65
65
|
this.func();
|
|
@@ -67,20 +67,20 @@ export class Expression extends IValue {
|
|
|
67
67
|
}
|
|
68
68
|
return this;
|
|
69
69
|
}
|
|
70
|
-
disable() {
|
|
70
|
+
$disable() {
|
|
71
71
|
if (this.isEnabled) {
|
|
72
72
|
for (let i = 0; i < this.values.length; i++) {
|
|
73
|
-
this.values[i]
|
|
73
|
+
this.values[i].$off(this.linkedFunc[i]);
|
|
74
74
|
}
|
|
75
75
|
this.isEnabled = false;
|
|
76
76
|
}
|
|
77
77
|
return this;
|
|
78
78
|
}
|
|
79
|
-
destroy() {
|
|
80
|
-
this
|
|
79
|
+
$destroy() {
|
|
80
|
+
this.$disable();
|
|
81
81
|
this.values.splice(0);
|
|
82
82
|
this.valuesCache.splice(0);
|
|
83
83
|
this.linkedFunc.splice(0);
|
|
84
|
-
super
|
|
84
|
+
super.$destroy();
|
|
85
85
|
}
|
|
86
86
|
}
|
package/lib/value/mirror.js
CHANGED
|
@@ -13,13 +13,13 @@ export class Mirror extends Reference {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(value, forwardOnly = false) {
|
|
15
15
|
super(value.$);
|
|
16
|
-
this
|
|
16
|
+
this.$handler = (v) => {
|
|
17
17
|
this.$ = v;
|
|
18
18
|
};
|
|
19
|
-
this
|
|
20
|
-
this
|
|
21
|
-
value
|
|
22
|
-
this
|
|
19
|
+
this.$pointedValue = value;
|
|
20
|
+
this.$forwardOnly = forwardOnly;
|
|
21
|
+
value.$on(this.$handler);
|
|
22
|
+
this.$seal();
|
|
23
23
|
}
|
|
24
24
|
get $() {
|
|
25
25
|
// this is a ts bug
|
|
@@ -28,29 +28,29 @@ export class Mirror extends Reference {
|
|
|
28
28
|
return super.$;
|
|
29
29
|
}
|
|
30
30
|
set $(v) {
|
|
31
|
-
if (!this
|
|
32
|
-
this
|
|
31
|
+
if (!this.$forwardOnly) {
|
|
32
|
+
this.$pointedValue.$ = v;
|
|
33
33
|
}
|
|
34
34
|
// this is a ts bug
|
|
35
35
|
// eslint-disable-next-line
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
super.$ = v;
|
|
38
38
|
}
|
|
39
|
-
enable() {
|
|
39
|
+
$enable() {
|
|
40
40
|
if (!this.isEnabled) {
|
|
41
41
|
this.isEnabled = true;
|
|
42
|
-
this
|
|
43
|
-
this.$ = this
|
|
42
|
+
this.$pointedValue.$on(this.$handler);
|
|
43
|
+
this.$ = this.$pointedValue.$;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
disable() {
|
|
46
|
+
$disable() {
|
|
47
47
|
if (this.isEnabled) {
|
|
48
|
-
this
|
|
48
|
+
this.$pointedValue.$off(this.$handler);
|
|
49
49
|
this.isEnabled = false;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
destroy() {
|
|
53
|
-
this
|
|
54
|
-
super
|
|
52
|
+
$destroy() {
|
|
53
|
+
this.$disable();
|
|
54
|
+
super.$destroy();
|
|
55
55
|
}
|
|
56
56
|
}
|
package/lib/value/pointer.js
CHANGED
|
@@ -16,11 +16,11 @@ export class Pointer extends Mirror {
|
|
|
16
16
|
* Point a new ivalue
|
|
17
17
|
* @param value {IValue} value to point
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
if (this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
19
|
+
set $$(value) {
|
|
20
|
+
if (this.$pointedValue !== value) {
|
|
21
|
+
this.$disable();
|
|
22
|
+
this.$pointedValue = value;
|
|
23
|
+
this.$enable();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
package/lib/value/reference.js
CHANGED
|
@@ -10,42 +10,42 @@ export class Reference extends IValue {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor(value) {
|
|
12
12
|
super(true);
|
|
13
|
-
this
|
|
14
|
-
this
|
|
15
|
-
this
|
|
13
|
+
this.$value = value;
|
|
14
|
+
this.$onchange = new Set;
|
|
15
|
+
this.$seal();
|
|
16
16
|
}
|
|
17
17
|
get $() {
|
|
18
|
-
return this
|
|
18
|
+
return this.$value;
|
|
19
19
|
}
|
|
20
20
|
set $(value) {
|
|
21
|
-
if (this
|
|
22
|
-
this
|
|
21
|
+
if (this.$value !== value) {
|
|
22
|
+
this.$value = value;
|
|
23
23
|
if (this.isEnabled) {
|
|
24
|
-
this
|
|
24
|
+
this.$onchange.forEach(handler => {
|
|
25
25
|
handler(value);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
enable() {
|
|
30
|
+
$enable() {
|
|
31
31
|
if (!this.isEnabled) {
|
|
32
|
-
this
|
|
33
|
-
handler(this
|
|
32
|
+
this.$onchange.forEach(handler => {
|
|
33
|
+
handler(this.$value);
|
|
34
34
|
});
|
|
35
35
|
this.isEnabled = true;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
disable() {
|
|
38
|
+
$disable() {
|
|
39
39
|
this.isEnabled = false;
|
|
40
40
|
}
|
|
41
|
-
on(handler) {
|
|
42
|
-
this
|
|
41
|
+
$on(handler) {
|
|
42
|
+
this.$onchange.add(handler);
|
|
43
43
|
}
|
|
44
|
-
off(handler) {
|
|
45
|
-
this
|
|
44
|
+
$off(handler) {
|
|
45
|
+
this.$onchange.delete(handler);
|
|
46
46
|
}
|
|
47
|
-
destroy() {
|
|
48
|
-
super
|
|
49
|
-
this
|
|
47
|
+
$destroy() {
|
|
48
|
+
super.$destroy();
|
|
49
|
+
this.$onchange.clear();
|
|
50
50
|
}
|
|
51
51
|
}
|
package/lib/views/base-view.js
CHANGED
package/lib/views/object-view.js
CHANGED
|
@@ -7,7 +7,7 @@ import { BaseView } from "./base-view";
|
|
|
7
7
|
export class ObjectView extends BaseView {
|
|
8
8
|
compose(input) {
|
|
9
9
|
super.compose(input);
|
|
10
|
-
const obj = input.model.
|
|
10
|
+
const obj = input.model.values;
|
|
11
11
|
for (const key in obj) {
|
|
12
12
|
this.createChild(input, key, obj[key]);
|
|
13
13
|
}
|
package/lib/views/repeat-node.js
CHANGED
|
@@ -12,11 +12,11 @@ export class RepeatNodePrivate extends INodePrivate {
|
|
|
12
12
|
* @type {Map}
|
|
13
13
|
*/
|
|
14
14
|
this.nodes = new Map();
|
|
15
|
-
this
|
|
15
|
+
this.$seal();
|
|
16
16
|
}
|
|
17
|
-
destroy() {
|
|
17
|
+
$destroy() {
|
|
18
18
|
this.nodes.clear();
|
|
19
|
-
super
|
|
19
|
+
super.$destroy();
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -58,7 +58,7 @@ export class RepeatNode extends Fragment {
|
|
|
58
58
|
const child = $.nodes.get(id);
|
|
59
59
|
if (child) {
|
|
60
60
|
child.remove();
|
|
61
|
-
child
|
|
61
|
+
child.$destroy();
|
|
62
62
|
this.$.nodes.delete(id);
|
|
63
63
|
this.children.delete(child);
|
|
64
64
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttributeBinding = void 0;
|
|
4
|
+
const binding_1 = require("./binding");
|
|
5
|
+
/**
|
|
6
|
+
* Represents an Attribute binding description
|
|
7
|
+
* @class AttributeBinding
|
|
8
|
+
* @extends Binding
|
|
9
|
+
*/
|
|
10
|
+
class AttributeBinding extends binding_1.Binding {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs an attribute binding description
|
|
13
|
+
* @param node {INode} the vasille node
|
|
14
|
+
* @param name {String} the name of attribute
|
|
15
|
+
* @param value {IValue} value to bind
|
|
16
|
+
*/
|
|
17
|
+
constructor(node, name, value) {
|
|
18
|
+
super(value);
|
|
19
|
+
this.init((value) => {
|
|
20
|
+
if (value) {
|
|
21
|
+
if (typeof value === 'boolean') {
|
|
22
|
+
node.node.setAttribute(name, "");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
node.node.setAttribute(name, `${value}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
node.node.removeAttribute(name);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.$seal();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.AttributeBinding = AttributeBinding;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Binding = void 0;
|
|
4
|
+
const destroyable_1 = require("../core/destroyable");
|
|
5
|
+
/**
|
|
6
|
+
* Describe a common binding logic
|
|
7
|
+
* @class Binding
|
|
8
|
+
* @extends Destroyable
|
|
9
|
+
*/
|
|
10
|
+
class Binding extends destroyable_1.Destroyable {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a common binding logic
|
|
13
|
+
* @param value {IValue} the value to bind
|
|
14
|
+
*/
|
|
15
|
+
constructor(value) {
|
|
16
|
+
super();
|
|
17
|
+
this.binding = value;
|
|
18
|
+
this.$seal();
|
|
19
|
+
}
|
|
20
|
+
init(bounded) {
|
|
21
|
+
this.func = bounded;
|
|
22
|
+
this.binding.$on(this.func);
|
|
23
|
+
this.func(this.binding.$);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Just clear bindings
|
|
27
|
+
*/
|
|
28
|
+
$destroy() {
|
|
29
|
+
this.binding.$off(this.func);
|
|
30
|
+
super.$destroy();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Binding = Binding;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
|
|
4
|
+
const binding_1 = require("./binding");
|
|
5
|
+
function addClass(node, cl) {
|
|
6
|
+
node.node.classList.add(cl);
|
|
7
|
+
}
|
|
8
|
+
function removeClass(node, cl) {
|
|
9
|
+
node.node.classList.remove(cl);
|
|
10
|
+
}
|
|
11
|
+
class StaticClassBinding extends binding_1.Binding {
|
|
12
|
+
constructor(node, name, value) {
|
|
13
|
+
super(value);
|
|
14
|
+
this.current = false;
|
|
15
|
+
this.init((value) => {
|
|
16
|
+
if (value !== this.current) {
|
|
17
|
+
if (value) {
|
|
18
|
+
addClass(node, name);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
removeClass(node, name);
|
|
22
|
+
}
|
|
23
|
+
this.current = value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
this.$seal();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.StaticClassBinding = StaticClassBinding;
|
|
30
|
+
class DynamicalClassBinding extends binding_1.Binding {
|
|
31
|
+
constructor(node, value) {
|
|
32
|
+
super(value);
|
|
33
|
+
this.current = "";
|
|
34
|
+
this.init((value) => {
|
|
35
|
+
if (this.current != value) {
|
|
36
|
+
if (this.current.length) {
|
|
37
|
+
removeClass(node, this.current);
|
|
38
|
+
}
|
|
39
|
+
if (value.length) {
|
|
40
|
+
addClass(node, value);
|
|
41
|
+
}
|
|
42
|
+
this.current = value;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.$seal();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.DynamicalClassBinding = DynamicalClassBinding;
|