vasille 2.0.4 → 2.0.5
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 +3 -3
- package/cdn/es2015.js +470 -529
- package/cdn/es5.js +490 -536
- package/flow-typed/vasille.js +176 -180
- package/lib/binding/attribute.js +6 -12
- package/lib/binding/binding.js +9 -19
- package/lib/binding/class.js +34 -42
- package/lib/binding/style.js +5 -11
- package/lib/core/core.js +24 -28
- package/lib/core/destroyable.js +2 -2
- package/lib/core/ivalue.js +15 -13
- package/lib/node/app.js +6 -6
- package/lib/node/interceptor.js +3 -3
- package/lib/node/node.js +306 -303
- package/lib/node/watch.js +8 -8
- package/lib/value/expression.js +3 -3
- package/lib/value/mirror.js +6 -8
- package/lib/value/reference.js +3 -7
- package/lib/views/array-view.js +2 -2
- package/lib/views/base-view.js +6 -6
- package/lib/views/map-view.js +2 -2
- package/lib/views/object-view.js +2 -2
- package/lib/views/repeat-node.js +16 -44
- package/lib/views/repeater.js +7 -7
- package/lib/views/set-view.js +3 -3
- package/package.json +1 -1
- package/types/binding/attribute.d.ts +0 -6
- package/types/binding/binding.d.ts +4 -13
- package/types/binding/class.d.ts +7 -19
- package/types/binding/style.d.ts +0 -6
- package/types/core/core.d.ts +31 -31
- package/types/core/destroyable.d.ts +2 -2
- package/types/core/ivalue.d.ts +13 -11
- package/types/models/array-model.d.ts +2 -2
- package/types/models/map-model.d.ts +2 -2
- package/types/models/model.d.ts +3 -1
- package/types/models/object-model.d.ts +2 -2
- package/types/models/set-model.d.ts +2 -2
- package/types/node/app.d.ts +3 -3
- package/types/node/interceptor.d.ts +2 -2
- package/types/node/node.d.ts +137 -140
- package/types/node/watch.d.ts +2 -2
- package/types/value/expression.d.ts +1 -1
- package/types/value/mirror.d.ts +3 -3
- package/types/value/reference.d.ts +5 -5
- package/types/views/array-view.d.ts +1 -1
- package/types/views/base-view.d.ts +4 -4
- package/types/views/map-view.d.ts +1 -1
- package/types/views/object-view.d.ts +1 -1
- package/types/views/repeat-node.d.ts +1 -1
- package/types/views/repeater.d.ts +3 -3
- package/types/views/set-view.d.ts +1 -1
package/cdn/es2015.js
CHANGED
|
@@ -862,7 +862,7 @@ class Destroyable {
|
|
|
862
862
|
* Make object fields non configurable
|
|
863
863
|
* @protected
|
|
864
864
|
*/
|
|
865
|
-
|
|
865
|
+
seal() {
|
|
866
866
|
const $ = this;
|
|
867
867
|
Object.keys($).forEach(i => {
|
|
868
868
|
// eslint-disable-next-line no-prototype-builtins
|
|
@@ -894,7 +894,7 @@ class Destroyable {
|
|
|
894
894
|
/**
|
|
895
895
|
* Garbage collector method
|
|
896
896
|
*/
|
|
897
|
-
|
|
897
|
+
destroy() {
|
|
898
898
|
// nothing here
|
|
899
899
|
}
|
|
900
900
|
}
|
|
@@ -902,12 +902,26 @@ class Destroyable {
|
|
|
902
902
|
window.Destroyable = Destroyable;
|
|
903
903
|
|
|
904
904
|
// ./lib/core/ivalue.js
|
|
905
|
+
class Switchable extends Destroyable {
|
|
906
|
+
/**
|
|
907
|
+
* Enable update handlers triggering
|
|
908
|
+
*/
|
|
909
|
+
enable() {
|
|
910
|
+
throw notOverwritten();
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* disable update handlers triggering
|
|
914
|
+
*/
|
|
915
|
+
disable() {
|
|
916
|
+
throw notOverwritten();
|
|
917
|
+
}
|
|
918
|
+
}
|
|
905
919
|
/**
|
|
906
920
|
* Interface which describes a value
|
|
907
921
|
* @class IValue
|
|
908
922
|
* @extends Destroyable
|
|
909
923
|
*/
|
|
910
|
-
class IValue extends
|
|
924
|
+
class IValue extends Switchable {
|
|
911
925
|
/**
|
|
912
926
|
* @param isEnabled {boolean} initial is enabled state
|
|
913
927
|
*/
|
|
@@ -943,20 +957,9 @@ class IValue extends Destroyable {
|
|
|
943
957
|
off(handler) {
|
|
944
958
|
throw notOverwritten();
|
|
945
959
|
}
|
|
946
|
-
/**
|
|
947
|
-
* Enable update handlers triggering
|
|
948
|
-
*/
|
|
949
|
-
enable() {
|
|
950
|
-
throw notOverwritten();
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* disable update handlers triggering
|
|
954
|
-
*/
|
|
955
|
-
disable() {
|
|
956
|
-
throw notOverwritten();
|
|
957
|
-
}
|
|
958
960
|
}
|
|
959
961
|
|
|
962
|
+
window.Switchable = Switchable;
|
|
960
963
|
window.IValue = IValue;
|
|
961
964
|
|
|
962
965
|
// ./lib/index.js
|
|
@@ -1001,7 +1004,7 @@ class Expression extends IValue {
|
|
|
1001
1004
|
else {
|
|
1002
1005
|
handler();
|
|
1003
1006
|
}
|
|
1004
|
-
this
|
|
1007
|
+
this.seal();
|
|
1005
1008
|
}
|
|
1006
1009
|
get $() {
|
|
1007
1010
|
return this.sync.$;
|
|
@@ -1037,12 +1040,12 @@ class Expression extends IValue {
|
|
|
1037
1040
|
}
|
|
1038
1041
|
return this;
|
|
1039
1042
|
}
|
|
1040
|
-
|
|
1043
|
+
destroy() {
|
|
1041
1044
|
this.disable();
|
|
1042
1045
|
this.values.splice(0);
|
|
1043
1046
|
this.valuesCache.splice(0);
|
|
1044
1047
|
this.linkedFunc.splice(0);
|
|
1045
|
-
super
|
|
1048
|
+
super.destroy();
|
|
1046
1049
|
}
|
|
1047
1050
|
}
|
|
1048
1051
|
|
|
@@ -1062,7 +1065,7 @@ class Reference extends IValue {
|
|
|
1062
1065
|
super(true);
|
|
1063
1066
|
this.value = value;
|
|
1064
1067
|
this.onchange = new Set;
|
|
1065
|
-
this
|
|
1068
|
+
this.seal();
|
|
1066
1069
|
}
|
|
1067
1070
|
get $() {
|
|
1068
1071
|
return this.value;
|
|
@@ -1084,22 +1087,18 @@ class Reference extends IValue {
|
|
|
1084
1087
|
});
|
|
1085
1088
|
this.isEnabled = true;
|
|
1086
1089
|
}
|
|
1087
|
-
return this;
|
|
1088
1090
|
}
|
|
1089
1091
|
disable() {
|
|
1090
1092
|
this.isEnabled = false;
|
|
1091
|
-
return this;
|
|
1092
1093
|
}
|
|
1093
1094
|
on(handler) {
|
|
1094
1095
|
this.onchange.add(handler);
|
|
1095
|
-
return this;
|
|
1096
1096
|
}
|
|
1097
1097
|
off(handler) {
|
|
1098
1098
|
this.onchange.delete(handler);
|
|
1099
|
-
return this;
|
|
1100
1099
|
}
|
|
1101
|
-
|
|
1102
|
-
super
|
|
1100
|
+
destroy() {
|
|
1101
|
+
super.destroy();
|
|
1103
1102
|
this.onchange.clear();
|
|
1104
1103
|
}
|
|
1105
1104
|
}
|
|
@@ -1127,7 +1126,7 @@ class Mirror extends Reference {
|
|
|
1127
1126
|
this.pointedValue = value;
|
|
1128
1127
|
this.forwardOnly = forwardOnly;
|
|
1129
1128
|
value.on(this.handler);
|
|
1130
|
-
this
|
|
1129
|
+
this.seal();
|
|
1131
1130
|
}
|
|
1132
1131
|
get $() {
|
|
1133
1132
|
// this is a ts bug
|
|
@@ -1136,13 +1135,13 @@ class Mirror extends Reference {
|
|
|
1136
1135
|
return super.$;
|
|
1137
1136
|
}
|
|
1138
1137
|
set $(v) {
|
|
1138
|
+
if (!this.forwardOnly) {
|
|
1139
|
+
this.pointedValue.$ = v;
|
|
1140
|
+
}
|
|
1139
1141
|
// this is a ts bug
|
|
1140
1142
|
// eslint-disable-next-line
|
|
1141
1143
|
// @ts-ignore
|
|
1142
1144
|
super.$ = v;
|
|
1143
|
-
if (!this.forwardOnly) {
|
|
1144
|
-
this.pointedValue.$ = v;
|
|
1145
|
-
}
|
|
1146
1145
|
}
|
|
1147
1146
|
enable() {
|
|
1148
1147
|
if (!this.isEnabled) {
|
|
@@ -1150,18 +1149,16 @@ class Mirror extends Reference {
|
|
|
1150
1149
|
this.pointedValue.on(this.handler);
|
|
1151
1150
|
this.$ = this.pointedValue.$;
|
|
1152
1151
|
}
|
|
1153
|
-
return this;
|
|
1154
1152
|
}
|
|
1155
1153
|
disable() {
|
|
1156
1154
|
if (this.isEnabled) {
|
|
1157
1155
|
this.pointedValue.off(this.handler);
|
|
1158
1156
|
this.isEnabled = false;
|
|
1159
1157
|
}
|
|
1160
|
-
return this;
|
|
1161
1158
|
}
|
|
1162
|
-
|
|
1159
|
+
destroy() {
|
|
1163
1160
|
this.disable();
|
|
1164
|
-
super
|
|
1161
|
+
super.destroy();
|
|
1165
1162
|
}
|
|
1166
1163
|
}
|
|
1167
1164
|
|
|
@@ -1205,33 +1202,24 @@ window.Pointer = Pointer;
|
|
|
1205
1202
|
class Binding extends Destroyable {
|
|
1206
1203
|
/**
|
|
1207
1204
|
* Constructs a common binding logic
|
|
1208
|
-
* @param node {INode} the vasille node
|
|
1209
|
-
* @param name {String} the name of property/attribute/class
|
|
1210
1205
|
* @param value {IValue} the value to bind
|
|
1211
1206
|
*/
|
|
1212
|
-
constructor(
|
|
1207
|
+
constructor(value) {
|
|
1213
1208
|
super();
|
|
1214
|
-
this.updateFunc = this.bound(name).bind(null, node);
|
|
1215
1209
|
this.binding = value;
|
|
1216
|
-
this.
|
|
1217
|
-
this.updateFunc(this.binding.$);
|
|
1218
|
-
this.$seal();
|
|
1210
|
+
this.seal();
|
|
1219
1211
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
* @throws Always throws and must be overloaded in child class
|
|
1225
|
-
*/
|
|
1226
|
-
bound(name) {
|
|
1227
|
-
throw notOverwritten();
|
|
1212
|
+
init(bounded) {
|
|
1213
|
+
this.func = bounded;
|
|
1214
|
+
this.binding.on(this.func);
|
|
1215
|
+
this.func(this.binding.$);
|
|
1228
1216
|
}
|
|
1229
1217
|
/**
|
|
1230
1218
|
* Just clear bindings
|
|
1231
1219
|
*/
|
|
1232
|
-
|
|
1233
|
-
this.binding.off(this.
|
|
1234
|
-
super
|
|
1220
|
+
destroy() {
|
|
1221
|
+
this.binding.off(this.func);
|
|
1222
|
+
super.destroy();
|
|
1235
1223
|
}
|
|
1236
1224
|
}
|
|
1237
1225
|
|
|
@@ -1270,16 +1258,18 @@ class ReactivePrivate extends Destroyable {
|
|
|
1270
1258
|
* @type {boolean}
|
|
1271
1259
|
*/
|
|
1272
1260
|
this.frozen = false;
|
|
1273
|
-
this
|
|
1261
|
+
this.seal();
|
|
1274
1262
|
}
|
|
1275
|
-
|
|
1263
|
+
destroy() {
|
|
1276
1264
|
var _a;
|
|
1277
|
-
this.watch.forEach(value => value
|
|
1265
|
+
this.watch.forEach(value => value.destroy());
|
|
1278
1266
|
this.watch.clear();
|
|
1279
|
-
this.bindings.forEach(binding => binding
|
|
1267
|
+
this.bindings.forEach(binding => binding.destroy());
|
|
1280
1268
|
this.bindings.clear();
|
|
1281
|
-
(
|
|
1282
|
-
|
|
1269
|
+
this.models.forEach(model => model.disableReactivity());
|
|
1270
|
+
this.models.clear();
|
|
1271
|
+
(_a = this.freezeExpr) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1272
|
+
super.destroy();
|
|
1283
1273
|
}
|
|
1284
1274
|
}
|
|
1285
1275
|
/**
|
|
@@ -1296,7 +1286,7 @@ class Reactive extends Destroyable {
|
|
|
1296
1286
|
* Create a reference
|
|
1297
1287
|
* @param value {*} value to reference
|
|
1298
1288
|
*/
|
|
1299
|
-
|
|
1289
|
+
ref(value) {
|
|
1300
1290
|
const $ = this.$;
|
|
1301
1291
|
const ref = new Reference(value);
|
|
1302
1292
|
$.watch.add(ref);
|
|
@@ -1306,7 +1296,7 @@ class Reactive extends Destroyable {
|
|
|
1306
1296
|
* Create a mirror
|
|
1307
1297
|
* @param value {IValue} value to mirror
|
|
1308
1298
|
*/
|
|
1309
|
-
|
|
1299
|
+
mirror(value) {
|
|
1310
1300
|
const mirror = new Mirror(value, false);
|
|
1311
1301
|
this.$.watch.add(mirror);
|
|
1312
1302
|
return mirror;
|
|
@@ -1315,7 +1305,7 @@ class Reactive extends Destroyable {
|
|
|
1315
1305
|
* Create a forward-only mirror
|
|
1316
1306
|
* @param value {IValue} value to mirror
|
|
1317
1307
|
*/
|
|
1318
|
-
|
|
1308
|
+
forward(value) {
|
|
1319
1309
|
const mirror = new Mirror(value, true);
|
|
1320
1310
|
this.$.watch.add(mirror);
|
|
1321
1311
|
return mirror;
|
|
@@ -1325,14 +1315,9 @@ class Reactive extends Destroyable {
|
|
|
1325
1315
|
* @param value {*} default value to point
|
|
1326
1316
|
* @param forwardOnly {boolean} forward only sync
|
|
1327
1317
|
*/
|
|
1328
|
-
|
|
1318
|
+
point(value, forwardOnly = false) {
|
|
1329
1319
|
const $ = this.$;
|
|
1330
|
-
const
|
|
1331
|
-
const pointer = new Pointer(ref, forwardOnly);
|
|
1332
|
-
// when value is an ivalue will be equal to ref
|
|
1333
|
-
if (value !== ref) {
|
|
1334
|
-
$.watch.add(ref);
|
|
1335
|
-
}
|
|
1320
|
+
const pointer = new Pointer(value, forwardOnly);
|
|
1336
1321
|
$.watch.add(pointer);
|
|
1337
1322
|
return pointer;
|
|
1338
1323
|
}
|
|
@@ -1340,15 +1325,15 @@ class Reactive extends Destroyable {
|
|
|
1340
1325
|
* Register a model
|
|
1341
1326
|
* @param model
|
|
1342
1327
|
*/
|
|
1343
|
-
|
|
1328
|
+
register(model) {
|
|
1344
1329
|
this.$.models.add(model);
|
|
1345
1330
|
return model;
|
|
1346
1331
|
}
|
|
1347
|
-
|
|
1332
|
+
watch(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
1348
1333
|
const $ = this.$;
|
|
1349
1334
|
$.watch.add(new Expression(func, !this.$.frozen, v1, v2, v3, v4, v5, v6, v7, v8, v9));
|
|
1350
1335
|
}
|
|
1351
|
-
|
|
1336
|
+
bind(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
1352
1337
|
const res = new Expression(func, !this.$.frozen, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
1353
1338
|
const $ = this.$;
|
|
1354
1339
|
$.watch.add(res);
|
|
@@ -1357,7 +1342,7 @@ class Reactive extends Destroyable {
|
|
|
1357
1342
|
/**
|
|
1358
1343
|
* Enable reactivity of fields
|
|
1359
1344
|
*/
|
|
1360
|
-
|
|
1345
|
+
enable() {
|
|
1361
1346
|
const $ = this.$;
|
|
1362
1347
|
if (!$.enabled) {
|
|
1363
1348
|
$.watch.forEach(watcher => {
|
|
@@ -1372,7 +1357,7 @@ class Reactive extends Destroyable {
|
|
|
1372
1357
|
/**
|
|
1373
1358
|
* Disable reactivity of fields
|
|
1374
1359
|
*/
|
|
1375
|
-
|
|
1360
|
+
disable() {
|
|
1376
1361
|
const $ = this.$;
|
|
1377
1362
|
if ($.enabled) {
|
|
1378
1363
|
$.watch.forEach(watcher => {
|
|
@@ -1390,7 +1375,7 @@ class Reactive extends Destroyable {
|
|
|
1390
1375
|
* @param onOff {function} on show feedback
|
|
1391
1376
|
* @param onOn {function} on hide feedback
|
|
1392
1377
|
*/
|
|
1393
|
-
|
|
1378
|
+
bindAlive(cond, onOff, onOn) {
|
|
1394
1379
|
const $ = this.$;
|
|
1395
1380
|
if ($.freezeExpr) {
|
|
1396
1381
|
throw wrongBinding("this component already have a freeze state");
|
|
@@ -1402,18 +1387,18 @@ class Reactive extends Destroyable {
|
|
|
1402
1387
|
$.frozen = !cond;
|
|
1403
1388
|
if (cond) {
|
|
1404
1389
|
onOn === null || onOn === void 0 ? void 0 : onOn();
|
|
1405
|
-
this
|
|
1390
|
+
this.enable();
|
|
1406
1391
|
}
|
|
1407
1392
|
else {
|
|
1408
1393
|
onOff === null || onOff === void 0 ? void 0 : onOff();
|
|
1409
|
-
this
|
|
1394
|
+
this.disable();
|
|
1410
1395
|
}
|
|
1411
1396
|
}, true, cond);
|
|
1412
1397
|
return this;
|
|
1413
1398
|
}
|
|
1414
|
-
|
|
1415
|
-
super
|
|
1416
|
-
this
|
|
1399
|
+
destroy() {
|
|
1400
|
+
super.destroy();
|
|
1401
|
+
this.$.destroy();
|
|
1417
1402
|
this.$ = null;
|
|
1418
1403
|
}
|
|
1419
1404
|
}
|
|
@@ -1430,7 +1415,7 @@ window.Reactive = Reactive;
|
|
|
1430
1415
|
class FragmentPrivate extends ReactivePrivate {
|
|
1431
1416
|
constructor() {
|
|
1432
1417
|
super();
|
|
1433
|
-
this
|
|
1418
|
+
this.seal();
|
|
1434
1419
|
}
|
|
1435
1420
|
/**
|
|
1436
1421
|
* Pre-initializes the base of a fragment
|
|
@@ -1444,10 +1429,10 @@ class FragmentPrivate extends ReactivePrivate {
|
|
|
1444
1429
|
/**
|
|
1445
1430
|
* Unlinks all bindings
|
|
1446
1431
|
*/
|
|
1447
|
-
|
|
1432
|
+
destroy() {
|
|
1448
1433
|
this.next = null;
|
|
1449
1434
|
this.prev = null;
|
|
1450
|
-
super
|
|
1435
|
+
super.destroy();
|
|
1451
1436
|
}
|
|
1452
1437
|
}
|
|
1453
1438
|
/**
|
|
@@ -1460,13 +1445,13 @@ class Fragment extends Reactive {
|
|
|
1460
1445
|
* @param $ {FragmentPrivate}
|
|
1461
1446
|
*/
|
|
1462
1447
|
constructor($) {
|
|
1463
|
-
super();
|
|
1448
|
+
super($ || new FragmentPrivate);
|
|
1464
1449
|
/**
|
|
1465
1450
|
* The children list
|
|
1466
1451
|
* @type Array
|
|
1467
1452
|
*/
|
|
1468
|
-
this
|
|
1469
|
-
this
|
|
1453
|
+
this.children = new Set;
|
|
1454
|
+
this.lastChild = null;
|
|
1470
1455
|
}
|
|
1471
1456
|
/**
|
|
1472
1457
|
* Gets the app of node
|
|
@@ -1480,43 +1465,38 @@ class Fragment extends Reactive {
|
|
|
1480
1465
|
* @param parent {Fragment} parent of node
|
|
1481
1466
|
* @param data {*} additional data
|
|
1482
1467
|
*/
|
|
1483
|
-
|
|
1468
|
+
preinit(app, parent, data) {
|
|
1484
1469
|
const $ = this.$;
|
|
1485
1470
|
$.preinit(app, parent);
|
|
1486
1471
|
}
|
|
1487
1472
|
/**
|
|
1488
1473
|
* Initialize node
|
|
1489
1474
|
*/
|
|
1490
|
-
|
|
1491
|
-
this
|
|
1492
|
-
this
|
|
1493
|
-
this
|
|
1494
|
-
this
|
|
1495
|
-
this.$mounted();
|
|
1475
|
+
init() {
|
|
1476
|
+
this.createWatchers();
|
|
1477
|
+
this.created();
|
|
1478
|
+
this.compose();
|
|
1479
|
+
this.mounted();
|
|
1496
1480
|
return this;
|
|
1497
1481
|
}
|
|
1498
1482
|
/** To be overloaded: created event handler */
|
|
1499
|
-
|
|
1483
|
+
created() {
|
|
1500
1484
|
// empty
|
|
1501
1485
|
}
|
|
1502
1486
|
/** To be overloaded: mounted event handler */
|
|
1503
|
-
|
|
1487
|
+
mounted() {
|
|
1504
1488
|
// empty
|
|
1505
1489
|
}
|
|
1506
1490
|
/** To be overloaded: ready event handler */
|
|
1507
|
-
|
|
1508
|
-
// empty
|
|
1509
|
-
}
|
|
1510
|
-
/** To be overloaded: signals creation milestone */
|
|
1511
|
-
$createSignals() {
|
|
1491
|
+
ready() {
|
|
1512
1492
|
// empty
|
|
1513
1493
|
}
|
|
1514
1494
|
/** To be overloaded: watchers creation milestone */
|
|
1515
|
-
|
|
1495
|
+
createWatchers() {
|
|
1516
1496
|
// empty
|
|
1517
1497
|
}
|
|
1518
1498
|
/** To be overloaded: DOM creation milestone */
|
|
1519
|
-
|
|
1499
|
+
compose() {
|
|
1520
1500
|
// empty
|
|
1521
1501
|
}
|
|
1522
1502
|
/**
|
|
@@ -1524,27 +1504,23 @@ class Fragment extends Reactive {
|
|
|
1524
1504
|
* @param node {Fragment} A node to push
|
|
1525
1505
|
* @protected
|
|
1526
1506
|
*/
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
lastChild = this.$children[this.$children.length - 1];
|
|
1531
|
-
}
|
|
1532
|
-
if (lastChild) {
|
|
1533
|
-
lastChild.$.next = node;
|
|
1507
|
+
pushNode(node) {
|
|
1508
|
+
if (this.lastChild) {
|
|
1509
|
+
this.lastChild.$.next = node;
|
|
1534
1510
|
}
|
|
1535
|
-
node.$.prev = lastChild;
|
|
1536
|
-
|
|
1537
|
-
this
|
|
1511
|
+
node.$.prev = this.lastChild;
|
|
1512
|
+
this.lastChild = node;
|
|
1513
|
+
this.children.add(node);
|
|
1538
1514
|
}
|
|
1539
1515
|
/**
|
|
1540
1516
|
* Find first node in element if so exists
|
|
1541
1517
|
* @return {?Element}
|
|
1542
1518
|
* @protected
|
|
1543
1519
|
*/
|
|
1544
|
-
|
|
1520
|
+
findFirstChild() {
|
|
1545
1521
|
let first;
|
|
1546
|
-
this
|
|
1547
|
-
first = first || child
|
|
1522
|
+
this.children.forEach(child => {
|
|
1523
|
+
first = first || child.findFirstChild();
|
|
1548
1524
|
});
|
|
1549
1525
|
return first;
|
|
1550
1526
|
}
|
|
@@ -1552,30 +1528,30 @@ class Fragment extends Reactive {
|
|
|
1552
1528
|
* Append a node to end of element
|
|
1553
1529
|
* @param node {Node} node to insert
|
|
1554
1530
|
*/
|
|
1555
|
-
|
|
1531
|
+
appendNode(node) {
|
|
1556
1532
|
const $ = this.$;
|
|
1557
1533
|
if ($.next) {
|
|
1558
|
-
$.next
|
|
1534
|
+
$.next.insertAdjacent(node);
|
|
1559
1535
|
}
|
|
1560
1536
|
else {
|
|
1561
|
-
$.parent
|
|
1537
|
+
$.parent.appendNode(node);
|
|
1562
1538
|
}
|
|
1563
1539
|
}
|
|
1564
1540
|
/**
|
|
1565
1541
|
* Insert a node as a sibling of this
|
|
1566
1542
|
* @param node {Node} node to insert
|
|
1567
1543
|
*/
|
|
1568
|
-
|
|
1569
|
-
const child = this
|
|
1544
|
+
insertAdjacent(node) {
|
|
1545
|
+
const child = this.findFirstChild();
|
|
1570
1546
|
const $ = this.$;
|
|
1571
1547
|
if (child) {
|
|
1572
|
-
$.app
|
|
1548
|
+
$.app.run.insertBefore(child, node);
|
|
1573
1549
|
}
|
|
1574
1550
|
else if ($.next) {
|
|
1575
|
-
$.next
|
|
1551
|
+
$.next.insertAdjacent(node);
|
|
1576
1552
|
}
|
|
1577
1553
|
else {
|
|
1578
|
-
$.parent
|
|
1554
|
+
$.parent.appendNode(node);
|
|
1579
1555
|
}
|
|
1580
1556
|
}
|
|
1581
1557
|
/**
|
|
@@ -1583,40 +1559,38 @@ class Fragment extends Reactive {
|
|
|
1583
1559
|
* @param text {String | IValue} A text fragment string
|
|
1584
1560
|
* @param cb {function (TextNode)} Callback if previous is slot name
|
|
1585
1561
|
*/
|
|
1586
|
-
|
|
1562
|
+
text(text, cb) {
|
|
1587
1563
|
const $ = this.$;
|
|
1588
1564
|
const node = new TextNode();
|
|
1589
|
-
const textValue = text instanceof IValue ? text : this
|
|
1590
|
-
node
|
|
1591
|
-
this
|
|
1565
|
+
const textValue = text instanceof IValue ? text : this.ref(text);
|
|
1566
|
+
node.preinit($.app, this, textValue);
|
|
1567
|
+
this.pushNode(node);
|
|
1592
1568
|
if (cb) {
|
|
1593
|
-
$.app
|
|
1569
|
+
$.app.run.callCallback(() => {
|
|
1594
1570
|
cb(node);
|
|
1595
1571
|
});
|
|
1596
1572
|
}
|
|
1597
|
-
return this;
|
|
1598
1573
|
}
|
|
1599
|
-
|
|
1600
|
-
if (this.$.app
|
|
1574
|
+
debug(text) {
|
|
1575
|
+
if (this.$.app.debugUi) {
|
|
1601
1576
|
const node = new DebugNode();
|
|
1602
|
-
node
|
|
1603
|
-
this
|
|
1577
|
+
node.preinit(this.$.app, this, text);
|
|
1578
|
+
this.pushNode(node);
|
|
1604
1579
|
}
|
|
1605
1580
|
return this;
|
|
1606
1581
|
}
|
|
1607
|
-
|
|
1582
|
+
tag(tagName, cb) {
|
|
1608
1583
|
const $ = this.$;
|
|
1609
1584
|
const node = new Tag();
|
|
1610
|
-
node
|
|
1611
|
-
node
|
|
1612
|
-
this
|
|
1613
|
-
$.app
|
|
1585
|
+
node.preinit($.app, this, tagName);
|
|
1586
|
+
node.init();
|
|
1587
|
+
this.pushNode(node);
|
|
1588
|
+
$.app.run.callCallback(() => {
|
|
1614
1589
|
if (cb) {
|
|
1615
1590
|
cb(node, node.node);
|
|
1616
1591
|
}
|
|
1617
|
-
node
|
|
1592
|
+
node.ready();
|
|
1618
1593
|
});
|
|
1619
|
-
return this;
|
|
1620
1594
|
}
|
|
1621
1595
|
/**
|
|
1622
1596
|
* Defines a custom element
|
|
@@ -1624,19 +1598,18 @@ class Fragment extends Reactive {
|
|
|
1624
1598
|
* @param callback {function($ : *)}
|
|
1625
1599
|
* @param callback1 {function($ : *)}
|
|
1626
1600
|
*/
|
|
1627
|
-
|
|
1601
|
+
create(node, callback, callback1) {
|
|
1628
1602
|
const $ = this.$;
|
|
1629
1603
|
node.$.parent = this;
|
|
1630
|
-
node
|
|
1604
|
+
node.preinit($.app, this);
|
|
1631
1605
|
if (callback) {
|
|
1632
1606
|
callback(node);
|
|
1633
1607
|
}
|
|
1634
1608
|
if (callback1) {
|
|
1635
1609
|
callback1(node);
|
|
1636
1610
|
}
|
|
1637
|
-
this
|
|
1638
|
-
node
|
|
1639
|
-
return this;
|
|
1611
|
+
this.pushNode(node);
|
|
1612
|
+
node.init().ready();
|
|
1640
1613
|
}
|
|
1641
1614
|
/**
|
|
1642
1615
|
* Defines an if node
|
|
@@ -1644,8 +1617,8 @@ class Fragment extends Reactive {
|
|
|
1644
1617
|
* @param cb {function(Fragment)} callback to run on true
|
|
1645
1618
|
* @return {this}
|
|
1646
1619
|
*/
|
|
1647
|
-
|
|
1648
|
-
return this
|
|
1620
|
+
if(cond, cb) {
|
|
1621
|
+
return this.switch({ cond, cb });
|
|
1649
1622
|
}
|
|
1650
1623
|
/**
|
|
1651
1624
|
* Defines a if-else node
|
|
@@ -1653,22 +1626,22 @@ class Fragment extends Reactive {
|
|
|
1653
1626
|
* @param ifCb {function(Fragment)} Call-back to create `if` child nodes
|
|
1654
1627
|
* @param elseCb {function(Fragment)} Call-back to create `else` child nodes
|
|
1655
1628
|
*/
|
|
1656
|
-
|
|
1657
|
-
return this
|
|
1629
|
+
if_else(ifCond, ifCb, elseCb) {
|
|
1630
|
+
return this.switch({ cond: ifCond, cb: ifCb }, { cond: trueIValue, cb: elseCb });
|
|
1658
1631
|
}
|
|
1659
1632
|
/**
|
|
1660
1633
|
* Defines a switch nodes: Will break after first true condition
|
|
1661
1634
|
* @param cases {...{ cond : IValue, cb : function(Fragment) }} cases
|
|
1662
1635
|
* @return {INode}
|
|
1663
1636
|
*/
|
|
1664
|
-
|
|
1637
|
+
switch(...cases) {
|
|
1665
1638
|
const $ = this.$;
|
|
1666
1639
|
const node = new SwitchedNode();
|
|
1667
|
-
node
|
|
1668
|
-
node
|
|
1669
|
-
this
|
|
1640
|
+
node.preinit($.app, this);
|
|
1641
|
+
node.init();
|
|
1642
|
+
this.pushNode(node);
|
|
1670
1643
|
node.setCases(cases);
|
|
1671
|
-
node
|
|
1644
|
+
node.ready();
|
|
1672
1645
|
return this;
|
|
1673
1646
|
}
|
|
1674
1647
|
/**
|
|
@@ -1677,22 +1650,48 @@ class Fragment extends Reactive {
|
|
|
1677
1650
|
* @param cb {function(Fragment) : void}
|
|
1678
1651
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
1679
1652
|
*/
|
|
1680
|
-
|
|
1653
|
+
case(cond, cb) {
|
|
1681
1654
|
return { cond, cb };
|
|
1682
1655
|
}
|
|
1683
1656
|
/**
|
|
1684
1657
|
* @param cb {(function(Fragment) : void)}
|
|
1685
1658
|
* @return {{cond : IValue, cb : (function(Fragment) : void)}}
|
|
1686
1659
|
*/
|
|
1687
|
-
|
|
1660
|
+
default(cb) {
|
|
1688
1661
|
return { cond: trueIValue, cb };
|
|
1689
1662
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1663
|
+
insertBefore(node) {
|
|
1664
|
+
const $ = this.$;
|
|
1665
|
+
node.$.prev = $.prev;
|
|
1666
|
+
node.$.next = this;
|
|
1667
|
+
if ($.prev) {
|
|
1668
|
+
$.prev.$.next = node;
|
|
1693
1669
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1670
|
+
$.prev = node;
|
|
1671
|
+
}
|
|
1672
|
+
insertAfter(node) {
|
|
1673
|
+
const $ = this.$;
|
|
1674
|
+
node.$.prev = this;
|
|
1675
|
+
node.$.next = $.next;
|
|
1676
|
+
$.next = node;
|
|
1677
|
+
}
|
|
1678
|
+
remove() {
|
|
1679
|
+
const $ = this.$;
|
|
1680
|
+
if ($.next) {
|
|
1681
|
+
$.next.$.prev = $.prev;
|
|
1682
|
+
}
|
|
1683
|
+
if ($.prev) {
|
|
1684
|
+
$.prev.$.next = $.next;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
destroy() {
|
|
1688
|
+
this.children.forEach(child => child.destroy());
|
|
1689
|
+
this.children.clear();
|
|
1690
|
+
this.lastChild = null;
|
|
1691
|
+
if (this.$.parent.lastChild === this) {
|
|
1692
|
+
this.$.parent.lastChild = this.$.prev;
|
|
1693
|
+
}
|
|
1694
|
+
super.destroy();
|
|
1696
1695
|
}
|
|
1697
1696
|
}
|
|
1698
1697
|
const trueIValue = new Reference(true);
|
|
@@ -1704,7 +1703,7 @@ const trueIValue = new Reference(true);
|
|
|
1704
1703
|
class TextNodePrivate extends FragmentPrivate {
|
|
1705
1704
|
constructor() {
|
|
1706
1705
|
super();
|
|
1707
|
-
this
|
|
1706
|
+
this.seal();
|
|
1708
1707
|
}
|
|
1709
1708
|
/**
|
|
1710
1709
|
* Pre-initializes a text node
|
|
@@ -1717,13 +1716,12 @@ class TextNodePrivate extends FragmentPrivate {
|
|
|
1717
1716
|
this.bindings.add(new Expression((v) => {
|
|
1718
1717
|
this.node.replaceData(0, -1, v);
|
|
1719
1718
|
}, true, text));
|
|
1720
|
-
this.parent.$$appendNode(this.node);
|
|
1721
1719
|
}
|
|
1722
1720
|
/**
|
|
1723
1721
|
* Clear node data
|
|
1724
1722
|
*/
|
|
1725
|
-
|
|
1726
|
-
super
|
|
1723
|
+
destroy() {
|
|
1724
|
+
super.destroy();
|
|
1727
1725
|
}
|
|
1728
1726
|
}
|
|
1729
1727
|
/**
|
|
@@ -1732,25 +1730,25 @@ class TextNodePrivate extends FragmentPrivate {
|
|
|
1732
1730
|
* @extends Fragment
|
|
1733
1731
|
*/
|
|
1734
1732
|
class TextNode extends Fragment {
|
|
1735
|
-
constructor() {
|
|
1736
|
-
super();
|
|
1737
|
-
this
|
|
1738
|
-
this.$seal();
|
|
1733
|
+
constructor($ = new TextNodePrivate()) {
|
|
1734
|
+
super($);
|
|
1735
|
+
this.seal();
|
|
1739
1736
|
}
|
|
1740
|
-
|
|
1737
|
+
preinit(app, parent, text) {
|
|
1741
1738
|
const $ = this.$;
|
|
1742
1739
|
if (!text) {
|
|
1743
1740
|
throw internalError('wrong TextNode::$preninit call');
|
|
1744
1741
|
}
|
|
1745
1742
|
$.preinitText(app, parent, text);
|
|
1743
|
+
$.parent.appendNode($.node);
|
|
1746
1744
|
}
|
|
1747
|
-
|
|
1745
|
+
findFirstChild() {
|
|
1748
1746
|
return this.$.node;
|
|
1749
1747
|
}
|
|
1750
|
-
|
|
1748
|
+
destroy() {
|
|
1751
1749
|
this.$.node.remove();
|
|
1752
|
-
this
|
|
1753
|
-
super
|
|
1750
|
+
this.$.destroy();
|
|
1751
|
+
super.destroy();
|
|
1754
1752
|
}
|
|
1755
1753
|
}
|
|
1756
1754
|
/**
|
|
@@ -1766,10 +1764,10 @@ class INodePrivate extends FragmentPrivate {
|
|
|
1766
1764
|
* @type {boolean}
|
|
1767
1765
|
*/
|
|
1768
1766
|
this.unmounted = false;
|
|
1769
|
-
this
|
|
1767
|
+
this.seal();
|
|
1770
1768
|
}
|
|
1771
|
-
|
|
1772
|
-
super
|
|
1769
|
+
destroy() {
|
|
1770
|
+
super.destroy();
|
|
1773
1771
|
}
|
|
1774
1772
|
}
|
|
1775
1773
|
/**
|
|
@@ -1784,7 +1782,7 @@ class INode extends Fragment {
|
|
|
1784
1782
|
*/
|
|
1785
1783
|
constructor($) {
|
|
1786
1784
|
super($ || new INodePrivate);
|
|
1787
|
-
this
|
|
1785
|
+
this.seal();
|
|
1788
1786
|
}
|
|
1789
1787
|
/**
|
|
1790
1788
|
* Get the bound node
|
|
@@ -1795,22 +1793,21 @@ class INode extends Fragment {
|
|
|
1795
1793
|
/**
|
|
1796
1794
|
* Initialize node
|
|
1797
1795
|
*/
|
|
1798
|
-
|
|
1799
|
-
this
|
|
1800
|
-
this
|
|
1801
|
-
this
|
|
1802
|
-
this
|
|
1803
|
-
this
|
|
1804
|
-
this
|
|
1805
|
-
this.$mounted();
|
|
1796
|
+
init() {
|
|
1797
|
+
this.createWatchers();
|
|
1798
|
+
this.createAttrs();
|
|
1799
|
+
this.createStyle();
|
|
1800
|
+
this.created();
|
|
1801
|
+
this.compose();
|
|
1802
|
+
this.mounted();
|
|
1806
1803
|
return this;
|
|
1807
1804
|
}
|
|
1808
1805
|
/** To be overloaded: attributes creation milestone */
|
|
1809
|
-
|
|
1806
|
+
createAttrs() {
|
|
1810
1807
|
// empty
|
|
1811
1808
|
}
|
|
1812
1809
|
/** To be overloaded: $style attributes creation milestone */
|
|
1813
|
-
|
|
1810
|
+
createStyle() {
|
|
1814
1811
|
// empty
|
|
1815
1812
|
}
|
|
1816
1813
|
/**
|
|
@@ -1818,42 +1815,40 @@ class INode extends Fragment {
|
|
|
1818
1815
|
* @param name {String} name of attribute
|
|
1819
1816
|
* @param value {IValue} value
|
|
1820
1817
|
*/
|
|
1821
|
-
|
|
1818
|
+
attr(name, value) {
|
|
1822
1819
|
const $ = this.$;
|
|
1823
1820
|
const attr = new AttributeBinding(this, name, value);
|
|
1824
1821
|
$.bindings.add(attr);
|
|
1825
|
-
return this;
|
|
1826
1822
|
}
|
|
1827
|
-
|
|
1823
|
+
bindAttr(name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
1828
1824
|
const $ = this.$;
|
|
1829
|
-
const expr = this
|
|
1825
|
+
const expr = this.bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
1830
1826
|
$.bindings.add(new AttributeBinding(this, name, expr));
|
|
1831
|
-
return this;
|
|
1832
1827
|
}
|
|
1833
1828
|
/**
|
|
1834
1829
|
* Set attribute value
|
|
1835
1830
|
* @param name {string} name of attribute
|
|
1836
1831
|
* @param value {string} value
|
|
1837
1832
|
*/
|
|
1838
|
-
|
|
1839
|
-
this.$.app
|
|
1833
|
+
setAttr(name, value) {
|
|
1834
|
+
this.$.app.run.setAttribute(this.$.node, name, value);
|
|
1840
1835
|
return this;
|
|
1841
1836
|
}
|
|
1842
1837
|
/**
|
|
1843
1838
|
* Adds a CSS class
|
|
1844
1839
|
* @param cl {string} Class name
|
|
1845
1840
|
*/
|
|
1846
|
-
|
|
1847
|
-
this.$.app
|
|
1841
|
+
addClass(cl) {
|
|
1842
|
+
this.$.app.run.addClass(this.$.node, cl);
|
|
1848
1843
|
return this;
|
|
1849
1844
|
}
|
|
1850
1845
|
/**
|
|
1851
1846
|
* Adds some CSS classes
|
|
1852
1847
|
* @param cls {...string} classes names
|
|
1853
1848
|
*/
|
|
1854
|
-
|
|
1849
|
+
addClasses(...cls) {
|
|
1855
1850
|
cls.forEach(cl => {
|
|
1856
|
-
this.$.app
|
|
1851
|
+
this.$.app.run.addClass(this.$.node, cl);
|
|
1857
1852
|
});
|
|
1858
1853
|
return this;
|
|
1859
1854
|
}
|
|
@@ -1861,9 +1856,9 @@ class INode extends Fragment {
|
|
|
1861
1856
|
* Bind a CSS class
|
|
1862
1857
|
* @param className {IValue}
|
|
1863
1858
|
*/
|
|
1864
|
-
|
|
1859
|
+
bindClass(className) {
|
|
1865
1860
|
const $ = this.$;
|
|
1866
|
-
$.bindings.add(new
|
|
1861
|
+
$.bindings.add(new DynamicalClassBinding(this, className));
|
|
1867
1862
|
return this;
|
|
1868
1863
|
}
|
|
1869
1864
|
/**
|
|
@@ -1871,8 +1866,8 @@ class INode extends Fragment {
|
|
|
1871
1866
|
* @param cond {IValue} condition
|
|
1872
1867
|
* @param className {string} class name
|
|
1873
1868
|
*/
|
|
1874
|
-
|
|
1875
|
-
this.$.bindings.add(new
|
|
1869
|
+
floatingClass(cond, className) {
|
|
1870
|
+
this.$.bindings.add(new StaticClassBinding(this, className, cond));
|
|
1876
1871
|
return this;
|
|
1877
1872
|
}
|
|
1878
1873
|
/**
|
|
@@ -1880,7 +1875,7 @@ class INode extends Fragment {
|
|
|
1880
1875
|
* @param name {String} name of style attribute
|
|
1881
1876
|
* @param value {IValue} value
|
|
1882
1877
|
*/
|
|
1883
|
-
|
|
1878
|
+
style(name, value) {
|
|
1884
1879
|
const $ = this.$;
|
|
1885
1880
|
if ($.node instanceof HTMLElement) {
|
|
1886
1881
|
$.bindings.add(new StyleBinding(this, name, value));
|
|
@@ -1890,9 +1885,9 @@ class INode extends Fragment {
|
|
|
1890
1885
|
}
|
|
1891
1886
|
return this;
|
|
1892
1887
|
}
|
|
1893
|
-
|
|
1888
|
+
bindStyle(name, calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
|
|
1894
1889
|
const $ = this.$;
|
|
1895
|
-
const expr = this
|
|
1890
|
+
const expr = this.bind(calculator, v1, v2, v3, v4, v5, v6, v7, v8, v9);
|
|
1896
1891
|
if ($.node instanceof HTMLElement) {
|
|
1897
1892
|
$.bindings.add(new StyleBinding(this, name, expr));
|
|
1898
1893
|
}
|
|
@@ -1906,9 +1901,9 @@ class INode extends Fragment {
|
|
|
1906
1901
|
* @param prop {string} Property name
|
|
1907
1902
|
* @param value {string} Property value
|
|
1908
1903
|
*/
|
|
1909
|
-
|
|
1904
|
+
setStyle(prop, value) {
|
|
1910
1905
|
if (this.$.node instanceof HTMLElement) {
|
|
1911
|
-
this.$.app
|
|
1906
|
+
this.$.app.run.setStyle(this.$.node, prop, value);
|
|
1912
1907
|
}
|
|
1913
1908
|
else {
|
|
1914
1909
|
throw userError("Style can be setted for HTML elements only", "non-html-element");
|
|
@@ -1921,7 +1916,7 @@ class INode extends Fragment {
|
|
|
1921
1916
|
* @param handler {function (Event)} Event handler
|
|
1922
1917
|
* @param options {Object | boolean} addEventListener options
|
|
1923
1918
|
*/
|
|
1924
|
-
|
|
1919
|
+
listen(name, handler, options) {
|
|
1925
1920
|
this.$.node.addEventListener(name, handler, options);
|
|
1926
1921
|
return this;
|
|
1927
1922
|
}
|
|
@@ -1929,395 +1924,395 @@ class INode extends Fragment {
|
|
|
1929
1924
|
* @param handler {function (MouseEvent)}
|
|
1930
1925
|
* @param options {Object | boolean}
|
|
1931
1926
|
*/
|
|
1932
|
-
|
|
1933
|
-
return this
|
|
1927
|
+
oncontextmenu(handler, options) {
|
|
1928
|
+
return this.listen("contextmenu", handler, options);
|
|
1934
1929
|
}
|
|
1935
1930
|
/**
|
|
1936
1931
|
* @param handler {function (MouseEvent)}
|
|
1937
1932
|
* @param options {Object | boolean}
|
|
1938
1933
|
*/
|
|
1939
|
-
|
|
1940
|
-
return this
|
|
1934
|
+
onmousedown(handler, options) {
|
|
1935
|
+
return this.listen("mousedown", handler, options);
|
|
1941
1936
|
}
|
|
1942
1937
|
/**
|
|
1943
1938
|
* @param handler {function (MouseEvent)}
|
|
1944
1939
|
* @param options {Object | boolean}
|
|
1945
1940
|
*/
|
|
1946
|
-
|
|
1947
|
-
return this
|
|
1941
|
+
onmouseenter(handler, options) {
|
|
1942
|
+
return this.listen("mouseenter", handler, options);
|
|
1948
1943
|
}
|
|
1949
1944
|
/**
|
|
1950
1945
|
* @param handler {function (MouseEvent)}
|
|
1951
1946
|
* @param options {Object | boolean}
|
|
1952
1947
|
*/
|
|
1953
|
-
|
|
1954
|
-
return this
|
|
1948
|
+
onmouseleave(handler, options) {
|
|
1949
|
+
return this.listen("mouseleave", handler, options);
|
|
1955
1950
|
}
|
|
1956
1951
|
/**
|
|
1957
1952
|
* @param handler {function (MouseEvent)}
|
|
1958
1953
|
* @param options {Object | boolean}
|
|
1959
1954
|
*/
|
|
1960
|
-
|
|
1961
|
-
return this
|
|
1955
|
+
onmousemove(handler, options) {
|
|
1956
|
+
return this.listen("mousemove", handler, options);
|
|
1962
1957
|
}
|
|
1963
1958
|
/**
|
|
1964
1959
|
* @param handler {function (MouseEvent)}
|
|
1965
1960
|
* @param options {Object | boolean}
|
|
1966
1961
|
*/
|
|
1967
|
-
|
|
1968
|
-
return this
|
|
1962
|
+
onmouseout(handler, options) {
|
|
1963
|
+
return this.listen("mouseout", handler, options);
|
|
1969
1964
|
}
|
|
1970
1965
|
/**
|
|
1971
1966
|
* @param handler {function (MouseEvent)}
|
|
1972
1967
|
* @param options {Object | boolean}
|
|
1973
1968
|
*/
|
|
1974
|
-
|
|
1975
|
-
return this
|
|
1969
|
+
onmouseover(handler, options) {
|
|
1970
|
+
return this.listen("mouseover", handler, options);
|
|
1976
1971
|
}
|
|
1977
1972
|
/**
|
|
1978
1973
|
* @param handler {function (MouseEvent)}
|
|
1979
1974
|
* @param options {Object | boolean}
|
|
1980
1975
|
*/
|
|
1981
|
-
|
|
1982
|
-
return this
|
|
1976
|
+
onmouseup(handler, options) {
|
|
1977
|
+
return this.listen("mouseup", handler, options);
|
|
1983
1978
|
}
|
|
1984
1979
|
/**
|
|
1985
1980
|
* @param handler {function (MouseEvent)}
|
|
1986
1981
|
* @param options {Object | boolean}
|
|
1987
1982
|
*/
|
|
1988
|
-
|
|
1989
|
-
return this
|
|
1983
|
+
onclick(handler, options) {
|
|
1984
|
+
return this.listen("click", handler, options);
|
|
1990
1985
|
}
|
|
1991
1986
|
/**
|
|
1992
1987
|
* @param handler {function (MouseEvent)}
|
|
1993
1988
|
* @param options {Object | boolean}
|
|
1994
1989
|
*/
|
|
1995
|
-
|
|
1996
|
-
return this
|
|
1990
|
+
ondblclick(handler, options) {
|
|
1991
|
+
return this.listen("dblclick", handler, options);
|
|
1997
1992
|
}
|
|
1998
1993
|
/**
|
|
1999
1994
|
* @param handler {function (FocusEvent)}
|
|
2000
1995
|
* @param options {Object | boolean}
|
|
2001
1996
|
*/
|
|
2002
|
-
|
|
2003
|
-
return this
|
|
1997
|
+
onblur(handler, options) {
|
|
1998
|
+
return this.listen("blur", handler, options);
|
|
2004
1999
|
}
|
|
2005
2000
|
/**
|
|
2006
2001
|
* @param handler {function (FocusEvent)}
|
|
2007
2002
|
* @param options {Object | boolean}
|
|
2008
2003
|
*/
|
|
2009
|
-
|
|
2010
|
-
return this
|
|
2004
|
+
onfocus(handler, options) {
|
|
2005
|
+
return this.listen("focus", handler, options);
|
|
2011
2006
|
}
|
|
2012
2007
|
/**
|
|
2013
2008
|
* @param handler {function (FocusEvent)}
|
|
2014
2009
|
* @param options {Object | boolean}
|
|
2015
2010
|
*/
|
|
2016
|
-
|
|
2017
|
-
return this
|
|
2011
|
+
onfocusin(handler, options) {
|
|
2012
|
+
return this.listen("focusin", handler, options);
|
|
2018
2013
|
}
|
|
2019
2014
|
/**
|
|
2020
2015
|
* @param handler {function (FocusEvent)}
|
|
2021
2016
|
* @param options {Object | boolean}
|
|
2022
2017
|
*/
|
|
2023
|
-
|
|
2024
|
-
return this
|
|
2018
|
+
onfocusout(handler, options) {
|
|
2019
|
+
return this.listen("focusout", handler, options);
|
|
2025
2020
|
}
|
|
2026
2021
|
/**
|
|
2027
2022
|
* @param handler {function (KeyboardEvent)}
|
|
2028
2023
|
* @param options {Object | boolean}
|
|
2029
2024
|
*/
|
|
2030
|
-
|
|
2031
|
-
return this
|
|
2025
|
+
onkeydown(handler, options) {
|
|
2026
|
+
return this.listen("keydown", handler, options);
|
|
2032
2027
|
}
|
|
2033
2028
|
/**
|
|
2034
2029
|
* @param handler {function (KeyboardEvent)}
|
|
2035
2030
|
* @param options {Object | boolean}
|
|
2036
2031
|
*/
|
|
2037
|
-
|
|
2038
|
-
return this
|
|
2032
|
+
onkeyup(handler, options) {
|
|
2033
|
+
return this.listen("keyup", handler, options);
|
|
2039
2034
|
}
|
|
2040
2035
|
/**
|
|
2041
2036
|
* @param handler {function (KeyboardEvent)}
|
|
2042
2037
|
* @param options {Object | boolean}
|
|
2043
2038
|
*/
|
|
2044
|
-
|
|
2045
|
-
return this
|
|
2039
|
+
onkeypress(handler, options) {
|
|
2040
|
+
return this.listen("keypress", handler, options);
|
|
2046
2041
|
}
|
|
2047
2042
|
/**
|
|
2048
2043
|
* @param handler {function (TouchEvent)}
|
|
2049
2044
|
* @param options {Object | boolean}
|
|
2050
2045
|
*/
|
|
2051
|
-
|
|
2052
|
-
return this
|
|
2046
|
+
ontouchstart(handler, options) {
|
|
2047
|
+
return this.listen("touchstart", handler, options);
|
|
2053
2048
|
}
|
|
2054
2049
|
/**
|
|
2055
2050
|
* @param handler {function (TouchEvent)}
|
|
2056
2051
|
* @param options {Object | boolean}
|
|
2057
2052
|
*/
|
|
2058
|
-
|
|
2059
|
-
return this
|
|
2053
|
+
ontouchmove(handler, options) {
|
|
2054
|
+
return this.listen("touchmove", handler, options);
|
|
2060
2055
|
}
|
|
2061
2056
|
/**
|
|
2062
2057
|
* @param handler {function (TouchEvent)}
|
|
2063
2058
|
* @param options {Object | boolean}
|
|
2064
2059
|
*/
|
|
2065
|
-
|
|
2066
|
-
return this
|
|
2060
|
+
ontouchend(handler, options) {
|
|
2061
|
+
return this.listen("touchend", handler, options);
|
|
2067
2062
|
}
|
|
2068
2063
|
/**
|
|
2069
2064
|
* @param handler {function (TouchEvent)}
|
|
2070
2065
|
* @param options {Object | boolean}
|
|
2071
2066
|
*/
|
|
2072
|
-
|
|
2073
|
-
return this
|
|
2067
|
+
ontouchcancel(handler, options) {
|
|
2068
|
+
return this.listen("touchcancel", handler, options);
|
|
2074
2069
|
}
|
|
2075
2070
|
/**
|
|
2076
2071
|
* @param handler {function (WheelEvent)}
|
|
2077
2072
|
* @param options {Object | boolean}
|
|
2078
2073
|
*/
|
|
2079
|
-
|
|
2080
|
-
return this
|
|
2074
|
+
onwheel(handler, options) {
|
|
2075
|
+
return this.listen("wheel", handler, options);
|
|
2081
2076
|
}
|
|
2082
2077
|
/**
|
|
2083
2078
|
* @param handler {function (ProgressEvent)}
|
|
2084
2079
|
* @param options {Object | boolean}
|
|
2085
2080
|
*/
|
|
2086
|
-
|
|
2087
|
-
return this
|
|
2081
|
+
onabort(handler, options) {
|
|
2082
|
+
return this.listen("abort", handler, options);
|
|
2088
2083
|
}
|
|
2089
2084
|
/**
|
|
2090
2085
|
* @param handler {function (ProgressEvent)}
|
|
2091
2086
|
* @param options {Object | boolean}
|
|
2092
2087
|
*/
|
|
2093
|
-
|
|
2094
|
-
return this
|
|
2088
|
+
onerror(handler, options) {
|
|
2089
|
+
return this.listen("error", handler, options);
|
|
2095
2090
|
}
|
|
2096
2091
|
/**
|
|
2097
2092
|
* @param handler {function (ProgressEvent)}
|
|
2098
2093
|
* @param options {Object | boolean}
|
|
2099
2094
|
*/
|
|
2100
|
-
|
|
2101
|
-
return this
|
|
2095
|
+
onload(handler, options) {
|
|
2096
|
+
return this.listen("load", handler, options);
|
|
2102
2097
|
}
|
|
2103
2098
|
/**
|
|
2104
2099
|
* @param handler {function (ProgressEvent)}
|
|
2105
2100
|
* @param options {Object | boolean}
|
|
2106
2101
|
*/
|
|
2107
|
-
|
|
2108
|
-
return this
|
|
2102
|
+
onloadend(handler, options) {
|
|
2103
|
+
return this.listen("loadend", handler, options);
|
|
2109
2104
|
}
|
|
2110
2105
|
/**
|
|
2111
2106
|
* @param handler {function (ProgressEvent)}
|
|
2112
2107
|
* @param options {Object | boolean}
|
|
2113
2108
|
*/
|
|
2114
|
-
|
|
2115
|
-
return this
|
|
2109
|
+
onloadstart(handler, options) {
|
|
2110
|
+
return this.listen("loadstart", handler, options);
|
|
2116
2111
|
}
|
|
2117
2112
|
/**
|
|
2118
2113
|
* @param handler {function (ProgressEvent)}
|
|
2119
2114
|
* @param options {Object | boolean}
|
|
2120
2115
|
*/
|
|
2121
|
-
|
|
2122
|
-
return this
|
|
2116
|
+
onprogress(handler, options) {
|
|
2117
|
+
return this.listen("progress", handler, options);
|
|
2123
2118
|
}
|
|
2124
2119
|
/**
|
|
2125
2120
|
* @param handler {function (ProgressEvent)}
|
|
2126
2121
|
* @param options {Object | boolean}
|
|
2127
2122
|
*/
|
|
2128
|
-
|
|
2129
|
-
return this
|
|
2123
|
+
ontimeout(handler, options) {
|
|
2124
|
+
return this.listen("timeout", handler, options);
|
|
2130
2125
|
}
|
|
2131
2126
|
/**
|
|
2132
2127
|
* @param handler {function (DragEvent)}
|
|
2133
2128
|
* @param options {Object | boolean}
|
|
2134
2129
|
*/
|
|
2135
|
-
|
|
2136
|
-
return this
|
|
2130
|
+
ondrag(handler, options) {
|
|
2131
|
+
return this.listen("drag", handler, options);
|
|
2137
2132
|
}
|
|
2138
2133
|
/**
|
|
2139
2134
|
* @param handler {function (DragEvent)}
|
|
2140
2135
|
* @param options {Object | boolean}
|
|
2141
2136
|
*/
|
|
2142
|
-
|
|
2143
|
-
return this
|
|
2137
|
+
ondragend(handler, options) {
|
|
2138
|
+
return this.listen("dragend", handler, options);
|
|
2144
2139
|
}
|
|
2145
2140
|
/**
|
|
2146
2141
|
* @param handler {function (DragEvent)}
|
|
2147
2142
|
* @param options {Object | boolean}
|
|
2148
2143
|
*/
|
|
2149
|
-
|
|
2150
|
-
return this
|
|
2144
|
+
ondragenter(handler, options) {
|
|
2145
|
+
return this.listen("dragenter", handler, options);
|
|
2151
2146
|
}
|
|
2152
2147
|
/**
|
|
2153
2148
|
* @param handler {function (DragEvent)}
|
|
2154
2149
|
* @param options {Object | boolean}
|
|
2155
2150
|
*/
|
|
2156
|
-
|
|
2157
|
-
return this
|
|
2151
|
+
ondragexit(handler, options) {
|
|
2152
|
+
return this.listen("dragexit", handler, options);
|
|
2158
2153
|
}
|
|
2159
2154
|
/**
|
|
2160
2155
|
* @param handler {function (DragEvent)}
|
|
2161
2156
|
* @param options {Object | boolean}
|
|
2162
2157
|
*/
|
|
2163
|
-
|
|
2164
|
-
return this
|
|
2158
|
+
ondragleave(handler, options) {
|
|
2159
|
+
return this.listen("dragleave", handler, options);
|
|
2165
2160
|
}
|
|
2166
2161
|
/**
|
|
2167
2162
|
* @param handler {function (DragEvent)}
|
|
2168
2163
|
* @param options {Object | boolean}
|
|
2169
2164
|
*/
|
|
2170
|
-
|
|
2171
|
-
return this
|
|
2165
|
+
ondragover(handler, options) {
|
|
2166
|
+
return this.listen("dragover", handler, options);
|
|
2172
2167
|
}
|
|
2173
2168
|
/**
|
|
2174
2169
|
* @param handler {function (DragEvent)}
|
|
2175
2170
|
* @param options {Object | boolean}
|
|
2176
2171
|
*/
|
|
2177
|
-
|
|
2178
|
-
return this
|
|
2172
|
+
ondragstart(handler, options) {
|
|
2173
|
+
return this.listen("dragstart", handler, options);
|
|
2179
2174
|
}
|
|
2180
2175
|
/**
|
|
2181
2176
|
* @param handler {function (DragEvent)}
|
|
2182
2177
|
* @param options {Object | boolean}
|
|
2183
2178
|
*/
|
|
2184
|
-
|
|
2185
|
-
return this
|
|
2179
|
+
ondrop(handler, options) {
|
|
2180
|
+
return this.listen("drop", handler, options);
|
|
2186
2181
|
}
|
|
2187
2182
|
/**
|
|
2188
2183
|
* @param handler {function (PointerEvent)}
|
|
2189
2184
|
* @param options {Object | boolean}
|
|
2190
2185
|
*/
|
|
2191
|
-
|
|
2192
|
-
return this
|
|
2186
|
+
onpointerover(handler, options) {
|
|
2187
|
+
return this.listen("pointerover", handler, options);
|
|
2193
2188
|
}
|
|
2194
2189
|
/**
|
|
2195
2190
|
* @param handler {function (PointerEvent)}
|
|
2196
2191
|
* @param options {Object | boolean}
|
|
2197
2192
|
*/
|
|
2198
|
-
|
|
2199
|
-
return this
|
|
2193
|
+
onpointerenter(handler, options) {
|
|
2194
|
+
return this.listen("pointerenter", handler, options);
|
|
2200
2195
|
}
|
|
2201
2196
|
/**
|
|
2202
2197
|
* @param handler {function (PointerEvent)}
|
|
2203
2198
|
* @param options {Object | boolean}
|
|
2204
2199
|
*/
|
|
2205
|
-
|
|
2206
|
-
return this
|
|
2200
|
+
onpointerdown(handler, options) {
|
|
2201
|
+
return this.listen("pointerdown", handler, options);
|
|
2207
2202
|
}
|
|
2208
2203
|
/**
|
|
2209
2204
|
* @param handler {function (PointerEvent)}
|
|
2210
2205
|
* @param options {Object | boolean}
|
|
2211
2206
|
*/
|
|
2212
|
-
|
|
2213
|
-
return this
|
|
2207
|
+
onpointermove(handler, options) {
|
|
2208
|
+
return this.listen("pointermove", handler, options);
|
|
2214
2209
|
}
|
|
2215
2210
|
/**
|
|
2216
2211
|
* @param handler {function (PointerEvent)}
|
|
2217
2212
|
* @param options {Object | boolean}
|
|
2218
2213
|
*/
|
|
2219
|
-
|
|
2220
|
-
return this
|
|
2214
|
+
onpointerup(handler, options) {
|
|
2215
|
+
return this.listen("pointerup", handler, options);
|
|
2221
2216
|
}
|
|
2222
2217
|
/**
|
|
2223
2218
|
* @param handler {function (PointerEvent)}
|
|
2224
2219
|
* @param options {Object | boolean}
|
|
2225
2220
|
*/
|
|
2226
|
-
|
|
2227
|
-
return this
|
|
2221
|
+
onpointercancel(handler, options) {
|
|
2222
|
+
return this.listen("pointercancel", handler, options);
|
|
2228
2223
|
}
|
|
2229
2224
|
/**
|
|
2230
2225
|
* @param handler {function (PointerEvent)}
|
|
2231
2226
|
* @param options {Object | boolean}
|
|
2232
2227
|
*/
|
|
2233
|
-
|
|
2234
|
-
return this
|
|
2228
|
+
onpointerout(handler, options) {
|
|
2229
|
+
return this.listen("pointerout", handler, options);
|
|
2235
2230
|
}
|
|
2236
2231
|
/**
|
|
2237
2232
|
* @param handler {function (PointerEvent)}
|
|
2238
2233
|
* @param options {Object | boolean}
|
|
2239
2234
|
*/
|
|
2240
|
-
|
|
2241
|
-
return this
|
|
2235
|
+
onpointerleave(handler, options) {
|
|
2236
|
+
return this.listen("pointerleave", handler, options);
|
|
2242
2237
|
}
|
|
2243
2238
|
/**
|
|
2244
2239
|
* @param handler {function (PointerEvent)}
|
|
2245
2240
|
* @param options {Object | boolean}
|
|
2246
2241
|
*/
|
|
2247
|
-
|
|
2248
|
-
return this
|
|
2242
|
+
ongotpointercapture(handler, options) {
|
|
2243
|
+
return this.listen("gotpointercapture", handler, options);
|
|
2249
2244
|
}
|
|
2250
2245
|
/**
|
|
2251
2246
|
* @param handler {function (PointerEvent)}
|
|
2252
2247
|
* @param options {Object | boolean}
|
|
2253
2248
|
*/
|
|
2254
|
-
|
|
2255
|
-
return this
|
|
2249
|
+
onlostpointercapture(handler, options) {
|
|
2250
|
+
return this.listen("lostpointercapture", handler, options);
|
|
2256
2251
|
}
|
|
2257
2252
|
/**
|
|
2258
2253
|
* @param handler {function (AnimationEvent)}
|
|
2259
2254
|
* @param options {Object | boolean}
|
|
2260
2255
|
*/
|
|
2261
|
-
|
|
2262
|
-
return this
|
|
2256
|
+
onanimationstart(handler, options) {
|
|
2257
|
+
return this.listen("animationstart", handler, options);
|
|
2263
2258
|
}
|
|
2264
2259
|
/**
|
|
2265
2260
|
* @param handler {function (AnimationEvent)}
|
|
2266
2261
|
* @param options {Object | boolean}
|
|
2267
2262
|
*/
|
|
2268
|
-
|
|
2269
|
-
return this
|
|
2263
|
+
onanimationend(handler, options) {
|
|
2264
|
+
return this.listen("animationend", handler, options);
|
|
2270
2265
|
}
|
|
2271
2266
|
/**
|
|
2272
2267
|
* @param handler {function (AnimationEvent)}
|
|
2273
2268
|
* @param options {Object | boolean}
|
|
2274
2269
|
*/
|
|
2275
|
-
|
|
2276
|
-
return this
|
|
2270
|
+
onanimationiteraton(handler, options) {
|
|
2271
|
+
return this.listen("animationiteration", handler, options);
|
|
2277
2272
|
}
|
|
2278
2273
|
/**
|
|
2279
2274
|
* @param handler {function (ClipboardEvent)}
|
|
2280
2275
|
* @param options {Object | boolean}
|
|
2281
2276
|
*/
|
|
2282
|
-
|
|
2283
|
-
return this
|
|
2277
|
+
onclipboardchange(handler, options) {
|
|
2278
|
+
return this.listen("clipboardchange", handler, options);
|
|
2284
2279
|
}
|
|
2285
2280
|
/**
|
|
2286
2281
|
* @param handler {function (ClipboardEvent)}
|
|
2287
2282
|
* @param options {Object | boolean}
|
|
2288
2283
|
*/
|
|
2289
|
-
|
|
2290
|
-
return this
|
|
2284
|
+
oncut(handler, options) {
|
|
2285
|
+
return this.listen("cut", handler, options);
|
|
2291
2286
|
}
|
|
2292
2287
|
/**
|
|
2293
2288
|
* @param handler {function (ClipboardEvent)}
|
|
2294
2289
|
* @param options {Object | boolean}
|
|
2295
2290
|
*/
|
|
2296
|
-
|
|
2297
|
-
return this
|
|
2291
|
+
oncopy(handler, options) {
|
|
2292
|
+
return this.listen("copy", handler, options);
|
|
2298
2293
|
}
|
|
2299
2294
|
/**
|
|
2300
2295
|
* @param handler {function (ClipboardEvent)}
|
|
2301
2296
|
* @param options {Object | boolean}
|
|
2302
2297
|
*/
|
|
2303
|
-
|
|
2304
|
-
return this
|
|
2298
|
+
onpaste(handler, options) {
|
|
2299
|
+
return this.listen("paste", handler, options);
|
|
2305
2300
|
}
|
|
2306
|
-
|
|
2301
|
+
insertAdjacent(node) {
|
|
2307
2302
|
const $ = this.$;
|
|
2308
|
-
$.app
|
|
2303
|
+
$.app.run.insertBefore($.node, node);
|
|
2309
2304
|
}
|
|
2310
2305
|
/**
|
|
2311
2306
|
* A v-show & ngShow alternative
|
|
2312
2307
|
* @param cond {IValue} show condition
|
|
2313
2308
|
*/
|
|
2314
|
-
|
|
2309
|
+
bindShow(cond) {
|
|
2315
2310
|
const $ = this.$;
|
|
2316
2311
|
const node = $.node;
|
|
2317
2312
|
if (node instanceof HTMLElement) {
|
|
2318
2313
|
let lastDisplay = node.style.display;
|
|
2319
2314
|
const htmlNode = node;
|
|
2320
|
-
return this
|
|
2315
|
+
return this.bindAlive(cond, () => {
|
|
2321
2316
|
lastDisplay = htmlNode.style.display;
|
|
2322
2317
|
htmlNode.style.display = 'none';
|
|
2323
2318
|
}, () => {
|
|
@@ -2332,12 +2327,12 @@ class INode extends Fragment {
|
|
|
2332
2327
|
* bind HTML
|
|
2333
2328
|
* @param value {IValue}
|
|
2334
2329
|
*/
|
|
2335
|
-
|
|
2330
|
+
html(value) {
|
|
2336
2331
|
const $ = this.$;
|
|
2337
2332
|
const node = $.node;
|
|
2338
2333
|
if (node instanceof HTMLElement) {
|
|
2339
2334
|
node.innerHTML = value.$;
|
|
2340
|
-
this
|
|
2335
|
+
this.watch((v) => {
|
|
2341
2336
|
node.innerHTML = v;
|
|
2342
2337
|
}, value);
|
|
2343
2338
|
}
|
|
@@ -2354,9 +2349,9 @@ class INode extends Fragment {
|
|
|
2354
2349
|
class Tag extends INode {
|
|
2355
2350
|
constructor() {
|
|
2356
2351
|
super();
|
|
2357
|
-
this
|
|
2352
|
+
this.seal();
|
|
2358
2353
|
}
|
|
2359
|
-
|
|
2354
|
+
preinit(app, parent, tagName) {
|
|
2360
2355
|
if (!tagName || typeof tagName !== "string") {
|
|
2361
2356
|
throw internalError('wrong Tag::$preinit call');
|
|
2362
2357
|
}
|
|
@@ -2364,55 +2359,50 @@ class Tag extends INode {
|
|
|
2364
2359
|
const $ = this.$;
|
|
2365
2360
|
$.preinit(app, parent);
|
|
2366
2361
|
$.node = node;
|
|
2367
|
-
$.parent
|
|
2362
|
+
$.parent.appendNode(node);
|
|
2368
2363
|
}
|
|
2369
|
-
|
|
2364
|
+
findFirstChild() {
|
|
2370
2365
|
return this.$.unmounted ? null : this.$.node;
|
|
2371
2366
|
}
|
|
2372
|
-
|
|
2367
|
+
insertAdjacent(node) {
|
|
2373
2368
|
if (this.$.unmounted) {
|
|
2374
2369
|
if (this.$.next) {
|
|
2375
|
-
this.$.next
|
|
2370
|
+
this.$.next.insertAdjacent(node);
|
|
2376
2371
|
}
|
|
2377
2372
|
else {
|
|
2378
|
-
this.$.parent
|
|
2373
|
+
this.$.parent.appendNode(node);
|
|
2379
2374
|
}
|
|
2380
2375
|
}
|
|
2381
2376
|
else {
|
|
2382
|
-
super
|
|
2377
|
+
super.insertAdjacent(node);
|
|
2383
2378
|
}
|
|
2384
2379
|
}
|
|
2385
|
-
|
|
2380
|
+
appendNode(node) {
|
|
2386
2381
|
const $ = this.$;
|
|
2387
|
-
$.app
|
|
2382
|
+
$.app.run.appendChild($.node, node);
|
|
2388
2383
|
}
|
|
2389
2384
|
/**
|
|
2390
2385
|
* Mount/Unmount a node
|
|
2391
2386
|
* @param cond {IValue} show condition
|
|
2392
2387
|
*/
|
|
2393
|
-
|
|
2388
|
+
bindMount(cond) {
|
|
2394
2389
|
const $ = this.$;
|
|
2395
|
-
|
|
2390
|
+
this.bindAlive(cond, () => {
|
|
2396
2391
|
$.node.remove();
|
|
2397
2392
|
$.unmounted = true;
|
|
2398
2393
|
}, () => {
|
|
2399
|
-
if (
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
$.next.$$insertAdjacent($.node);
|
|
2403
|
-
}
|
|
2404
|
-
else {
|
|
2405
|
-
$.parent.$$appendNode($.node);
|
|
2394
|
+
if ($.unmounted) {
|
|
2395
|
+
this.insertAdjacent($.node);
|
|
2396
|
+
$.unmounted = false;
|
|
2406
2397
|
}
|
|
2407
|
-
$.unmounted = false;
|
|
2408
2398
|
});
|
|
2409
2399
|
}
|
|
2410
2400
|
/**
|
|
2411
2401
|
* Runs GC
|
|
2412
2402
|
*/
|
|
2413
|
-
|
|
2403
|
+
destroy() {
|
|
2414
2404
|
this.node.remove();
|
|
2415
|
-
super
|
|
2405
|
+
super.destroy();
|
|
2416
2406
|
}
|
|
2417
2407
|
}
|
|
2418
2408
|
/**
|
|
@@ -2421,7 +2411,7 @@ class Tag extends INode {
|
|
|
2421
2411
|
* @extends INode
|
|
2422
2412
|
*/
|
|
2423
2413
|
class Extension extends INode {
|
|
2424
|
-
|
|
2414
|
+
preinit(app, parent) {
|
|
2425
2415
|
if (parent instanceof INode) {
|
|
2426
2416
|
const $ = this.$;
|
|
2427
2417
|
$.preinit(app, parent);
|
|
@@ -2433,10 +2423,10 @@ class Extension extends INode {
|
|
|
2433
2423
|
}
|
|
2434
2424
|
constructor($) {
|
|
2435
2425
|
super($);
|
|
2436
|
-
this
|
|
2426
|
+
this.seal();
|
|
2437
2427
|
}
|
|
2438
|
-
|
|
2439
|
-
super
|
|
2428
|
+
destroy() {
|
|
2429
|
+
super.destroy();
|
|
2440
2430
|
}
|
|
2441
2431
|
}
|
|
2442
2432
|
/**
|
|
@@ -2447,14 +2437,14 @@ class Extension extends INode {
|
|
|
2447
2437
|
class Component extends Extension {
|
|
2448
2438
|
constructor() {
|
|
2449
2439
|
super();
|
|
2450
|
-
this
|
|
2440
|
+
this.seal();
|
|
2451
2441
|
}
|
|
2452
|
-
|
|
2453
|
-
super
|
|
2454
|
-
if (this
|
|
2442
|
+
mounted() {
|
|
2443
|
+
super.mounted();
|
|
2444
|
+
if (this.children.size !== 1) {
|
|
2455
2445
|
throw userError("Component must have a child only", "dom-error");
|
|
2456
2446
|
}
|
|
2457
|
-
const child = this
|
|
2447
|
+
const child = this.lastChild;
|
|
2458
2448
|
if (child instanceof Tag || child instanceof Component) {
|
|
2459
2449
|
const $ = this.$;
|
|
2460
2450
|
$.node = child.node;
|
|
@@ -2463,7 +2453,7 @@ class Component extends Extension {
|
|
|
2463
2453
|
throw userError("Component child must be Tag or Component", "dom-error");
|
|
2464
2454
|
}
|
|
2465
2455
|
}
|
|
2466
|
-
|
|
2456
|
+
preinit(app, parent) {
|
|
2467
2457
|
this.$.preinit(app, parent);
|
|
2468
2458
|
}
|
|
2469
2459
|
}
|
|
@@ -2472,21 +2462,21 @@ class Component extends Extension {
|
|
|
2472
2462
|
* @class SwitchedNodePrivate
|
|
2473
2463
|
* @extends INodePrivate
|
|
2474
2464
|
*/
|
|
2475
|
-
class SwitchedNodePrivate extends
|
|
2465
|
+
class SwitchedNodePrivate extends FragmentPrivate {
|
|
2476
2466
|
constructor() {
|
|
2477
2467
|
super();
|
|
2478
|
-
this
|
|
2468
|
+
this.seal();
|
|
2479
2469
|
}
|
|
2480
2470
|
/**
|
|
2481
2471
|
* Runs GC
|
|
2482
2472
|
*/
|
|
2483
|
-
|
|
2473
|
+
destroy() {
|
|
2484
2474
|
this.cases.forEach(c => {
|
|
2485
2475
|
delete c.cond;
|
|
2486
2476
|
delete c.cb;
|
|
2487
2477
|
});
|
|
2488
2478
|
this.cases.splice(0);
|
|
2489
|
-
super
|
|
2479
|
+
super.destroy();
|
|
2490
2480
|
}
|
|
2491
2481
|
}
|
|
2492
2482
|
/**
|
|
@@ -2509,10 +2499,10 @@ class SwitchedNode extends Fragment {
|
|
|
2509
2499
|
if (i === $.index) {
|
|
2510
2500
|
return;
|
|
2511
2501
|
}
|
|
2512
|
-
if (
|
|
2513
|
-
|
|
2514
|
-
this
|
|
2515
|
-
|
|
2502
|
+
if (this.lastChild) {
|
|
2503
|
+
this.lastChild.destroy();
|
|
2504
|
+
this.children.clear();
|
|
2505
|
+
this.lastChild = null;
|
|
2516
2506
|
}
|
|
2517
2507
|
if (i !== $.cases.length) {
|
|
2518
2508
|
$.index = i;
|
|
@@ -2522,7 +2512,7 @@ class SwitchedNode extends Fragment {
|
|
|
2522
2512
|
$.index = -1;
|
|
2523
2513
|
}
|
|
2524
2514
|
};
|
|
2525
|
-
this
|
|
2515
|
+
this.seal();
|
|
2526
2516
|
}
|
|
2527
2517
|
/**
|
|
2528
2518
|
* Set up switch cases
|
|
@@ -2538,27 +2528,25 @@ class SwitchedNode extends Fragment {
|
|
|
2538
2528
|
*/
|
|
2539
2529
|
createChild(cb) {
|
|
2540
2530
|
const node = new Fragment();
|
|
2541
|
-
node
|
|
2542
|
-
node
|
|
2543
|
-
node
|
|
2544
|
-
this
|
|
2545
|
-
this.$children.push(node);
|
|
2531
|
+
node.preinit(this.$.app, this);
|
|
2532
|
+
node.init();
|
|
2533
|
+
this.lastChild = node;
|
|
2534
|
+
this.children.add(node);
|
|
2546
2535
|
cb(node);
|
|
2547
2536
|
}
|
|
2548
|
-
|
|
2537
|
+
ready() {
|
|
2549
2538
|
const $ = this.$;
|
|
2550
|
-
super.$ready();
|
|
2551
2539
|
$.cases.forEach(c => {
|
|
2552
2540
|
c.cond.on($.sync);
|
|
2553
2541
|
});
|
|
2554
2542
|
$.sync();
|
|
2555
2543
|
}
|
|
2556
|
-
|
|
2544
|
+
destroy() {
|
|
2557
2545
|
const $ = this.$;
|
|
2558
2546
|
$.cases.forEach(c => {
|
|
2559
2547
|
c.cond.off($.sync);
|
|
2560
2548
|
});
|
|
2561
|
-
super
|
|
2549
|
+
super.destroy();
|
|
2562
2550
|
}
|
|
2563
2551
|
}
|
|
2564
2552
|
/**
|
|
@@ -2567,7 +2555,7 @@ class SwitchedNode extends Fragment {
|
|
|
2567
2555
|
class DebugPrivate extends FragmentPrivate {
|
|
2568
2556
|
constructor() {
|
|
2569
2557
|
super();
|
|
2570
|
-
this
|
|
2558
|
+
this.seal();
|
|
2571
2559
|
}
|
|
2572
2560
|
/**
|
|
2573
2561
|
* Pre-initializes a text node
|
|
@@ -2581,14 +2569,14 @@ class DebugPrivate extends FragmentPrivate {
|
|
|
2581
2569
|
this.bindings.add(new Expression((v) => {
|
|
2582
2570
|
this.node.replaceData(0, -1, v);
|
|
2583
2571
|
}, true, text));
|
|
2584
|
-
this.parent
|
|
2572
|
+
this.parent.appendNode(this.node);
|
|
2585
2573
|
}
|
|
2586
2574
|
/**
|
|
2587
2575
|
* Clear node data
|
|
2588
2576
|
*/
|
|
2589
|
-
|
|
2577
|
+
destroy() {
|
|
2590
2578
|
this.node.remove();
|
|
2591
|
-
super
|
|
2579
|
+
super.destroy();
|
|
2592
2580
|
}
|
|
2593
2581
|
}
|
|
2594
2582
|
/**
|
|
@@ -2604,9 +2592,9 @@ class DebugNode extends Fragment {
|
|
|
2604
2592
|
* @type {DebugNode}
|
|
2605
2593
|
*/
|
|
2606
2594
|
this.$ = new DebugPrivate();
|
|
2607
|
-
this
|
|
2595
|
+
this.seal();
|
|
2608
2596
|
}
|
|
2609
|
-
|
|
2597
|
+
preinit(app, parent, text) {
|
|
2610
2598
|
const $ = this.$;
|
|
2611
2599
|
if (!text) {
|
|
2612
2600
|
throw internalError('wrong DebugNode::$preninit call');
|
|
@@ -2616,9 +2604,9 @@ class DebugNode extends Fragment {
|
|
|
2616
2604
|
/**
|
|
2617
2605
|
* Runs garbage collector
|
|
2618
2606
|
*/
|
|
2619
|
-
|
|
2620
|
-
this
|
|
2621
|
-
super
|
|
2607
|
+
destroy() {
|
|
2608
|
+
this.$.destroy();
|
|
2609
|
+
super.destroy();
|
|
2622
2610
|
}
|
|
2623
2611
|
}
|
|
2624
2612
|
|
|
@@ -2647,8 +2635,8 @@ class AppNode extends INode {
|
|
|
2647
2635
|
*/
|
|
2648
2636
|
constructor(options) {
|
|
2649
2637
|
super();
|
|
2650
|
-
this
|
|
2651
|
-
this
|
|
2638
|
+
this.run = (options === null || options === void 0 ? void 0 : options.executor) || ((options === null || options === void 0 ? void 0 : options.freezeUi) === false ? timeoutExecutor : instantExecutor);
|
|
2639
|
+
this.debugUi = (options === null || options === void 0 ? void 0 : options.debugUi) || false;
|
|
2652
2640
|
}
|
|
2653
2641
|
}
|
|
2654
2642
|
/**
|
|
@@ -2665,12 +2653,12 @@ class App extends AppNode {
|
|
|
2665
2653
|
constructor(node, options) {
|
|
2666
2654
|
super(options);
|
|
2667
2655
|
this.$.node = node;
|
|
2668
|
-
this
|
|
2669
|
-
this
|
|
2656
|
+
this.preinit(this, this);
|
|
2657
|
+
this.seal();
|
|
2670
2658
|
}
|
|
2671
|
-
|
|
2659
|
+
appendNode(node) {
|
|
2672
2660
|
const $ = this.$;
|
|
2673
|
-
|
|
2661
|
+
this.run.appendChild($.node, node);
|
|
2674
2662
|
}
|
|
2675
2663
|
}
|
|
2676
2664
|
|
|
@@ -2725,8 +2713,8 @@ class Interceptor extends Destroyable {
|
|
|
2725
2713
|
signal.unsubscribe(handler);
|
|
2726
2714
|
});
|
|
2727
2715
|
}
|
|
2728
|
-
|
|
2729
|
-
super
|
|
2716
|
+
destroy() {
|
|
2717
|
+
super.destroy();
|
|
2730
2718
|
this.signals.forEach(signal => {
|
|
2731
2719
|
this.handlers.forEach(handler => {
|
|
2732
2720
|
signal.unsubscribe(handler);
|
|
@@ -2753,7 +2741,7 @@ class InterceptorNode extends Fragment {
|
|
|
2753
2741
|
*/
|
|
2754
2742
|
this.slot = new Slot;
|
|
2755
2743
|
}
|
|
2756
|
-
|
|
2744
|
+
compose() {
|
|
2757
2745
|
this.slot.release(this, this.interceptor);
|
|
2758
2746
|
}
|
|
2759
2747
|
}
|
|
@@ -2775,22 +2763,16 @@ class AttributeBinding extends Binding {
|
|
|
2775
2763
|
* @param value {IValue} value to bind
|
|
2776
2764
|
*/
|
|
2777
2765
|
constructor(node, name, value) {
|
|
2778
|
-
super(
|
|
2779
|
-
|
|
2780
|
-
/**
|
|
2781
|
-
* Generates a function which updates the attribute value
|
|
2782
|
-
* @param name {String} The name of attribute
|
|
2783
|
-
* @returns {Function} a function which will update attribute value
|
|
2784
|
-
*/
|
|
2785
|
-
bound(name) {
|
|
2786
|
-
return function (node, value) {
|
|
2766
|
+
super(value);
|
|
2767
|
+
this.init((value) => {
|
|
2787
2768
|
if (value) {
|
|
2788
|
-
node.app
|
|
2769
|
+
node.app.run.setAttribute(node.node, name, value);
|
|
2789
2770
|
}
|
|
2790
2771
|
else {
|
|
2791
|
-
node.app
|
|
2772
|
+
node.app.run.removeAttribute(node.node, name);
|
|
2792
2773
|
}
|
|
2793
|
-
};
|
|
2774
|
+
});
|
|
2775
|
+
this.seal();
|
|
2794
2776
|
}
|
|
2795
2777
|
}
|
|
2796
2778
|
|
|
@@ -2810,77 +2792,64 @@ class StyleBinding extends Binding {
|
|
|
2810
2792
|
* @param value {IValue} the value to bind
|
|
2811
2793
|
*/
|
|
2812
2794
|
constructor(node, name, value) {
|
|
2813
|
-
super(
|
|
2814
|
-
|
|
2815
|
-
/**
|
|
2816
|
-
* Generates a function to update style property value
|
|
2817
|
-
* @param name {string}
|
|
2818
|
-
* @returns {Function} a function to update style property
|
|
2819
|
-
*/
|
|
2820
|
-
bound(name) {
|
|
2821
|
-
return function (node, value) {
|
|
2795
|
+
super(value);
|
|
2796
|
+
this.init((value) => {
|
|
2822
2797
|
if (node.node instanceof HTMLElement) {
|
|
2823
|
-
node.app
|
|
2798
|
+
node.app.run.setStyle(node.node, name, value);
|
|
2824
2799
|
}
|
|
2825
|
-
};
|
|
2800
|
+
});
|
|
2801
|
+
this.seal();
|
|
2826
2802
|
}
|
|
2827
2803
|
}
|
|
2828
2804
|
|
|
2829
2805
|
window.StyleBinding = StyleBinding;
|
|
2830
2806
|
|
|
2831
2807
|
// ./lib/binding/class.js
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
* Constructs an HTML class binding description
|
|
2840
|
-
* @param node {INode} the vasille node
|
|
2841
|
-
* @param name {String} the name of class
|
|
2842
|
-
* @param value {IValue} the value to bind
|
|
2843
|
-
*/
|
|
2808
|
+
function addClass(node, cl) {
|
|
2809
|
+
node.app.run.addClass(node.node, cl);
|
|
2810
|
+
}
|
|
2811
|
+
function removeClass(node, cl) {
|
|
2812
|
+
node.app.run.removeClass(node.node, cl);
|
|
2813
|
+
}
|
|
2814
|
+
class StaticClassBinding extends Binding {
|
|
2844
2815
|
constructor(node, name, value) {
|
|
2845
|
-
super(
|
|
2846
|
-
this
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
* @returns {Function} a function which will update attribute value
|
|
2852
|
-
*/
|
|
2853
|
-
bound(name) {
|
|
2854
|
-
let current = null;
|
|
2855
|
-
function addClass(node, cl) {
|
|
2856
|
-
node.app.$run.addClass(node.node, cl);
|
|
2857
|
-
}
|
|
2858
|
-
function removeClass(node, cl) {
|
|
2859
|
-
node.app.$run.removeClass(node.node, cl);
|
|
2860
|
-
}
|
|
2861
|
-
return (node, value) => {
|
|
2862
|
-
if (value !== current) {
|
|
2863
|
-
if (typeof current === "string" && current !== "") {
|
|
2864
|
-
removeClass(node, current);
|
|
2816
|
+
super(value);
|
|
2817
|
+
this.current = false;
|
|
2818
|
+
this.init((value) => {
|
|
2819
|
+
if (value !== this.current) {
|
|
2820
|
+
if (value) {
|
|
2821
|
+
addClass(node, name);
|
|
2865
2822
|
}
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2823
|
+
else {
|
|
2824
|
+
removeClass(node, name);
|
|
2825
|
+
}
|
|
2826
|
+
this.current = value;
|
|
2827
|
+
}
|
|
2828
|
+
});
|
|
2829
|
+
this.seal();
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
class DynamicalClassBinding extends Binding {
|
|
2833
|
+
constructor(node, value) {
|
|
2834
|
+
super(value);
|
|
2835
|
+
this.current = "";
|
|
2836
|
+
this.init((value) => {
|
|
2837
|
+
if (this.current != value) {
|
|
2838
|
+
if (this.current.length) {
|
|
2839
|
+
removeClass(node, this.current);
|
|
2873
2840
|
}
|
|
2874
|
-
|
|
2841
|
+
if (value.length) {
|
|
2875
2842
|
addClass(node, value);
|
|
2876
2843
|
}
|
|
2877
|
-
current = value;
|
|
2844
|
+
this.current = value;
|
|
2878
2845
|
}
|
|
2879
|
-
};
|
|
2846
|
+
});
|
|
2847
|
+
this.seal();
|
|
2880
2848
|
}
|
|
2881
2849
|
}
|
|
2882
2850
|
|
|
2883
|
-
window.
|
|
2851
|
+
window.StaticClassBinding = StaticClassBinding;
|
|
2852
|
+
window.DynamicalClassBinding = DynamicalClassBinding;
|
|
2884
2853
|
|
|
2885
2854
|
// ./lib/views/repeat-node.js
|
|
2886
2855
|
/**
|
|
@@ -2896,11 +2865,11 @@ class RepeatNodePrivate extends INodePrivate {
|
|
|
2896
2865
|
* @type {Map}
|
|
2897
2866
|
*/
|
|
2898
2867
|
this.nodes = new Map();
|
|
2899
|
-
this
|
|
2868
|
+
this.seal();
|
|
2900
2869
|
}
|
|
2901
|
-
|
|
2870
|
+
destroy() {
|
|
2902
2871
|
this.nodes.clear();
|
|
2903
|
-
super
|
|
2872
|
+
super.destroy();
|
|
2904
2873
|
}
|
|
2905
2874
|
}
|
|
2906
2875
|
/**
|
|
@@ -2920,43 +2889,27 @@ class RepeatNode extends Fragment {
|
|
|
2920
2889
|
createChild(id, item, before) {
|
|
2921
2890
|
// TODO: Refactor: remove @ts-ignore
|
|
2922
2891
|
const node = new Fragment();
|
|
2923
|
-
// eslint-disable-next-line
|
|
2924
|
-
// @ts-ignore
|
|
2925
|
-
const $ = node.$;
|
|
2926
2892
|
this.destroyChild(id, item);
|
|
2927
2893
|
if (before) {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
// @ts-ignore
|
|
2931
|
-
$.prev = before.$.prev;
|
|
2932
|
-
// eslint-disable-next-line
|
|
2933
|
-
// @ts-ignore
|
|
2934
|
-
before.$.prev = node;
|
|
2935
|
-
if ($.prev) {
|
|
2936
|
-
// eslint-disable-next-line
|
|
2937
|
-
// @ts-ignore
|
|
2938
|
-
$.prev.$.next = node;
|
|
2939
|
-
}
|
|
2940
|
-
this.$children.splice(this.$children.indexOf(before), 0, node);
|
|
2894
|
+
this.children.add(node);
|
|
2895
|
+
before.insertBefore(node);
|
|
2941
2896
|
}
|
|
2942
2897
|
else {
|
|
2943
|
-
const lastChild = this
|
|
2898
|
+
const lastChild = this.lastChild;
|
|
2944
2899
|
if (lastChild) {
|
|
2945
|
-
|
|
2946
|
-
// @ts-ignore
|
|
2947
|
-
lastChild.$.next = node;
|
|
2900
|
+
lastChild.insertAfter(node);
|
|
2948
2901
|
}
|
|
2949
|
-
|
|
2950
|
-
this.$children.push(node);
|
|
2902
|
+
this.children.add(node);
|
|
2951
2903
|
}
|
|
2952
|
-
|
|
2953
|
-
node
|
|
2904
|
+
this.lastChild = node;
|
|
2905
|
+
node.preinit(this.$.app, this);
|
|
2906
|
+
node.init();
|
|
2954
2907
|
const callback = () => {
|
|
2955
2908
|
this.slot.release(node, item, id);
|
|
2956
|
-
node
|
|
2909
|
+
node.ready();
|
|
2957
2910
|
};
|
|
2958
2911
|
if (this.freezeUi) {
|
|
2959
|
-
this.$.app
|
|
2912
|
+
this.$.app.run.callCallback(callback);
|
|
2960
2913
|
}
|
|
2961
2914
|
else {
|
|
2962
2915
|
timeoutExecutor.callCallback(callback);
|
|
@@ -2967,22 +2920,10 @@ class RepeatNode extends Fragment {
|
|
|
2967
2920
|
const $ = this.$;
|
|
2968
2921
|
const child = $.nodes.get(id);
|
|
2969
2922
|
if (child) {
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
const $ = child.$;
|
|
2973
|
-
if ($.prev) {
|
|
2974
|
-
// eslint-disable-next-line
|
|
2975
|
-
// @ts-ignore
|
|
2976
|
-
$.prev.$.next = $.next;
|
|
2977
|
-
}
|
|
2978
|
-
if ($.next) {
|
|
2979
|
-
// eslint-disable-next-line
|
|
2980
|
-
// @ts-ignore
|
|
2981
|
-
$.next.$.prev = $.prev;
|
|
2982
|
-
}
|
|
2983
|
-
child.$destroy();
|
|
2923
|
+
child.remove();
|
|
2924
|
+
child.destroy();
|
|
2984
2925
|
this.$.nodes.delete(id);
|
|
2985
|
-
this
|
|
2926
|
+
this.children.delete(child);
|
|
2986
2927
|
}
|
|
2987
2928
|
}
|
|
2988
2929
|
}
|
|
@@ -3003,7 +2944,7 @@ class RepeaterPrivate extends RepeatNodePrivate {
|
|
|
3003
2944
|
* Current count of child nodes
|
|
3004
2945
|
*/
|
|
3005
2946
|
this.currentCount = 0;
|
|
3006
|
-
this
|
|
2947
|
+
this.seal();
|
|
3007
2948
|
}
|
|
3008
2949
|
}
|
|
3009
2950
|
/**
|
|
@@ -3018,7 +2959,7 @@ class Repeater extends RepeatNode {
|
|
|
3018
2959
|
* The count of children
|
|
3019
2960
|
*/
|
|
3020
2961
|
this.count = new Reference(0);
|
|
3021
|
-
this
|
|
2962
|
+
this.seal();
|
|
3022
2963
|
}
|
|
3023
2964
|
/**
|
|
3024
2965
|
* Changes the children count
|
|
@@ -3037,18 +2978,18 @@ class Repeater extends RepeatNode {
|
|
|
3037
2978
|
}
|
|
3038
2979
|
$.currentCount = number;
|
|
3039
2980
|
}
|
|
3040
|
-
|
|
2981
|
+
created() {
|
|
3041
2982
|
const $ = this.$;
|
|
3042
|
-
super
|
|
2983
|
+
super.created();
|
|
3043
2984
|
$.updateHandler = this.changeCount.bind(this);
|
|
3044
2985
|
this.count.on($.updateHandler);
|
|
3045
2986
|
}
|
|
3046
|
-
|
|
2987
|
+
ready() {
|
|
3047
2988
|
this.changeCount(this.count.$);
|
|
3048
2989
|
}
|
|
3049
|
-
|
|
2990
|
+
destroy() {
|
|
3050
2991
|
const $ = this.$;
|
|
3051
|
-
super
|
|
2992
|
+
super.destroy();
|
|
3052
2993
|
this.count.off($.updateHandler);
|
|
3053
2994
|
}
|
|
3054
2995
|
}
|
|
@@ -3065,7 +3006,7 @@ window.Repeater = Repeater;
|
|
|
3065
3006
|
class BaseViewPrivate extends RepeatNodePrivate {
|
|
3066
3007
|
constructor() {
|
|
3067
3008
|
super();
|
|
3068
|
-
this
|
|
3009
|
+
this.seal();
|
|
3069
3010
|
}
|
|
3070
3011
|
}
|
|
3071
3012
|
/**
|
|
@@ -3084,25 +3025,25 @@ class BaseView extends RepeatNode {
|
|
|
3084
3025
|
$.removeHandler = (id, item) => {
|
|
3085
3026
|
this.destroyChild(id, item);
|
|
3086
3027
|
};
|
|
3087
|
-
this
|
|
3028
|
+
this.seal();
|
|
3088
3029
|
}
|
|
3089
3030
|
/**
|
|
3090
3031
|
* Handle ready event
|
|
3091
3032
|
*/
|
|
3092
|
-
|
|
3033
|
+
ready() {
|
|
3093
3034
|
const $ = this.$;
|
|
3094
3035
|
this.model.listener.onAdd($.addHandler);
|
|
3095
3036
|
this.model.listener.onRemove($.removeHandler);
|
|
3096
|
-
super
|
|
3037
|
+
super.ready();
|
|
3097
3038
|
}
|
|
3098
3039
|
/**
|
|
3099
3040
|
* Handles destroy event
|
|
3100
3041
|
*/
|
|
3101
|
-
|
|
3042
|
+
destroy() {
|
|
3102
3043
|
const $ = this.$;
|
|
3103
3044
|
this.model.listener.offAdd($.addHandler);
|
|
3104
3045
|
this.model.listener.offRemove($.removeHandler);
|
|
3105
|
-
super
|
|
3046
|
+
super.destroy();
|
|
3106
3047
|
}
|
|
3107
3048
|
}
|
|
3108
3049
|
|
|
@@ -3123,11 +3064,11 @@ class ArrayView extends BaseView {
|
|
|
3123
3064
|
createChild(id, item, before) {
|
|
3124
3065
|
super.createChild(item, item, before || this.$.nodes.get(id));
|
|
3125
3066
|
}
|
|
3126
|
-
|
|
3067
|
+
ready() {
|
|
3127
3068
|
this.model.forEach(item => {
|
|
3128
3069
|
this.createChild(item, item);
|
|
3129
3070
|
});
|
|
3130
|
-
super
|
|
3071
|
+
super.ready();
|
|
3131
3072
|
}
|
|
3132
3073
|
}
|
|
3133
3074
|
|
|
@@ -3143,19 +3084,19 @@ class Watch extends Fragment {
|
|
|
3143
3084
|
constructor() {
|
|
3144
3085
|
super();
|
|
3145
3086
|
this.slot = new Slot;
|
|
3146
|
-
this.model = this
|
|
3147
|
-
this
|
|
3087
|
+
this.model = this.ref(null);
|
|
3088
|
+
this.seal();
|
|
3148
3089
|
}
|
|
3149
|
-
|
|
3150
|
-
this
|
|
3151
|
-
this
|
|
3152
|
-
child
|
|
3090
|
+
createWatchers() {
|
|
3091
|
+
this.watch((value) => {
|
|
3092
|
+
this.children.forEach(child => {
|
|
3093
|
+
child.destroy();
|
|
3153
3094
|
});
|
|
3154
|
-
this
|
|
3095
|
+
this.children.clear();
|
|
3155
3096
|
this.slot.release(this, value);
|
|
3156
3097
|
}, this.model);
|
|
3157
3098
|
}
|
|
3158
|
-
|
|
3099
|
+
compose() {
|
|
3159
3100
|
this.slot.release(this, this.model.$);
|
|
3160
3101
|
}
|
|
3161
3102
|
}
|
|
@@ -3173,12 +3114,12 @@ class ObjectView extends BaseView {
|
|
|
3173
3114
|
super();
|
|
3174
3115
|
this.model = model;
|
|
3175
3116
|
}
|
|
3176
|
-
|
|
3117
|
+
ready() {
|
|
3177
3118
|
const obj = this.model;
|
|
3178
3119
|
for (const key in obj) {
|
|
3179
3120
|
this.createChild(key, obj[key]);
|
|
3180
3121
|
}
|
|
3181
|
-
super
|
|
3122
|
+
super.ready();
|
|
3182
3123
|
}
|
|
3183
3124
|
}
|
|
3184
3125
|
|
|
@@ -3195,12 +3136,12 @@ class MapView extends BaseView {
|
|
|
3195
3136
|
super();
|
|
3196
3137
|
this.model = model;
|
|
3197
3138
|
}
|
|
3198
|
-
|
|
3139
|
+
ready() {
|
|
3199
3140
|
const map = this.model;
|
|
3200
3141
|
map.forEach((value, key) => {
|
|
3201
3142
|
this.createChild(key, value);
|
|
3202
3143
|
});
|
|
3203
|
-
super
|
|
3144
|
+
super.ready();
|
|
3204
3145
|
}
|
|
3205
3146
|
}
|
|
3206
3147
|
|
|
@@ -3217,15 +3158,15 @@ class SetView extends BaseView {
|
|
|
3217
3158
|
super();
|
|
3218
3159
|
this.model = model;
|
|
3219
3160
|
}
|
|
3220
|
-
|
|
3161
|
+
ready() {
|
|
3221
3162
|
const $ = this.$;
|
|
3222
3163
|
const set = this.model;
|
|
3223
3164
|
set.forEach(item => {
|
|
3224
|
-
$.app
|
|
3165
|
+
$.app.run.callCallback(() => {
|
|
3225
3166
|
this.createChild(item, item);
|
|
3226
3167
|
});
|
|
3227
3168
|
});
|
|
3228
|
-
super
|
|
3169
|
+
super.ready();
|
|
3229
3170
|
}
|
|
3230
3171
|
}
|
|
3231
3172
|
|