vsn 0.1.31 → 0.1.34
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/demo/demo.html +0 -11
- package/demo/vsn.js +1 -1
- package/dist/EventDispatcher.js +1 -1
- package/dist/EventDispatcher.js.map +1 -1
- package/dist/Scope/ScopeDataAbstract.d.ts +1 -1
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope/WrappedArray.d.ts +5 -2
- package/dist/Scope/WrappedArray.js +27 -0
- package/dist/Scope/WrappedArray.js.map +1 -1
- package/dist/Scope/properties/ArrayProperty.d.ts +8 -0
- package/dist/Scope/properties/ArrayProperty.js +51 -0
- package/dist/Scope/properties/ArrayProperty.js.map +1 -0
- package/dist/Scope/properties/Property.d.ts +6 -3
- package/dist/Scope/properties/Property.js +8 -0
- package/dist/Scope/properties/Property.js.map +1 -1
- package/dist/Scope/properties/_imports.d.ts +2 -0
- package/dist/Scope/properties/_imports.js +9 -0
- package/dist/Scope/properties/_imports.js.map +1 -0
- package/dist/attributes/_imports.d.ts +0 -1
- package/dist/attributes/_imports.js +1 -3
- package/dist/attributes/_imports.js.map +1 -1
- package/dist/vsn.d.ts +1 -2
- package/dist/vsn.js +2 -6
- package/dist/vsn.js.map +1 -1
- package/package.json +1 -1
- package/src/EventDispatcher.ts +1 -1
- package/src/Scope/ScopeDataAbstract.ts +1 -1
- package/src/Scope/WrappedArray.ts +27 -1
- package/src/Scope/properties/ArrayProperty.ts +30 -0
- package/src/Scope/properties/Property.ts +15 -4
- package/src/Scope/properties/_imports.ts +2 -0
- package/src/attributes/_imports.ts +0 -1
- package/src/vsn.ts +1 -3
- package/test/Scope/WrappedArray.spec.ts +11 -0
- package/test/Scope/properties/ArrayProperty.spec.ts +16 -0
- package/dist/Model/Field.d.ts +0 -8
- package/dist/Model/Field.js +0 -38
- package/dist/Model/Field.js.map +0 -1
- package/dist/attributes/Radio.d.ts +0 -13
- package/dist/attributes/Radio.js +0 -174
- package/dist/attributes/Radio.js.map +0 -1
- package/src/Model/Field.ts +0 -20
- package/src/attributes/Radio.ts +0 -54
package/dist/Model/Field.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.Field = void 0;
|
|
19
|
-
var Property_1 = require("../Scope/properties/Property");
|
|
20
|
-
var Registry_1 = require("../Registry");
|
|
21
|
-
var Field = /** @class */ (function (_super) {
|
|
22
|
-
__extends(Field, _super);
|
|
23
|
-
function Field() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
}
|
|
26
|
-
Field.prototype.validate = function () {
|
|
27
|
-
var errors = [];
|
|
28
|
-
for (var _i = 0, _a = this.config.validators || []; _i < _a.length; _i++) {
|
|
29
|
-
var validatorName = _a[_i];
|
|
30
|
-
var validator = Registry_1.Registry.instance.validators.getSynchronous(validatorName);
|
|
31
|
-
errors.concat(validator(this.value));
|
|
32
|
-
}
|
|
33
|
-
return errors;
|
|
34
|
-
};
|
|
35
|
-
return Field;
|
|
36
|
-
}(Property_1.Property));
|
|
37
|
-
exports.Field = Field;
|
|
38
|
-
//# sourceMappingURL=Field.js.map
|
package/dist/Model/Field.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../src/Model/Field.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAuE;AACvE,wCAAqC;AAMrC;IAA2B,yBAAQ;IAAnC;;IAYA,CAAC;IATG,wBAAQ,GAAR;QACI,IAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAA2B,UAA4B,EAA5B,KAAA,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,EAA5B,cAA4B,EAA5B,IAA4B,EAAE;YAArD,IAAM,aAAa,SAAA;YACnB,IAAM,SAAS,GAAG,mBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAC7E,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;SACxC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IACL,YAAC;AAAD,CAAC,AAZD,CAA2B,mBAAQ,GAYlC;AAZY,sBAAK"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Attribute } from "../Attribute";
|
|
2
|
-
import { Scope } from "../Scope";
|
|
3
|
-
export declare class Radio extends Attribute {
|
|
4
|
-
static readonly canDefer: boolean;
|
|
5
|
-
protected key?: string;
|
|
6
|
-
protected boundScope?: Scope;
|
|
7
|
-
setup(): Promise<void>;
|
|
8
|
-
extract(): Promise<void>;
|
|
9
|
-
connect(): Promise<void>;
|
|
10
|
-
evaluate(): Promise<void>;
|
|
11
|
-
handleEvent(e: any): Promise<void>;
|
|
12
|
-
checkSelected(): Promise<void>;
|
|
13
|
-
}
|
package/dist/attributes/Radio.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
-
function step(op) {
|
|
37
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
-
while (_) try {
|
|
39
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
40
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
-
switch (op[0]) {
|
|
42
|
-
case 0: case 1: t = op; break;
|
|
43
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
-
default:
|
|
47
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
-
if (t[2]) _.ops.pop();
|
|
52
|
-
_.trys.pop(); continue;
|
|
53
|
-
}
|
|
54
|
-
op = body.call(thisArg, _);
|
|
55
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.Radio = void 0;
|
|
61
|
-
var Registry_1 = require("../Registry");
|
|
62
|
-
var Attribute_1 = require("../Attribute");
|
|
63
|
-
var Radio = /** @class */ (function (_super) {
|
|
64
|
-
__extends(Radio, _super);
|
|
65
|
-
function Radio() {
|
|
66
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
67
|
-
}
|
|
68
|
-
Radio.prototype.setup = function () {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var scopeKey, ref, _a, _b;
|
|
71
|
-
return __generator(this, function (_c) {
|
|
72
|
-
switch (_c.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
scopeKey = this.getAttributeValue() || this.tag.getRawAttributeValue('name');
|
|
75
|
-
try {
|
|
76
|
-
ref = this.tag.scope.getReference(scopeKey);
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
console.error('error', e);
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
_a = this;
|
|
83
|
-
return [4 /*yield*/, ref.getKey()];
|
|
84
|
-
case 1:
|
|
85
|
-
_a.key = _c.sent();
|
|
86
|
-
_b = this;
|
|
87
|
-
return [4 /*yield*/, ref.getScope()];
|
|
88
|
-
case 2:
|
|
89
|
-
_b.boundScope = _c.sent();
|
|
90
|
-
return [4 /*yield*/, _super.prototype.setup.call(this)];
|
|
91
|
-
case 3:
|
|
92
|
-
_c.sent();
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
Radio.prototype.extract = function () {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0:
|
|
103
|
-
if (!this.tag.checked) return [3 /*break*/, 2];
|
|
104
|
-
return [4 /*yield*/, this.handleEvent(null)];
|
|
105
|
-
case 1:
|
|
106
|
-
_a.sent();
|
|
107
|
-
_a.label = 2;
|
|
108
|
-
case 2: return [4 /*yield*/, _super.prototype.extract.call(this)];
|
|
109
|
-
case 3:
|
|
110
|
-
_a.sent();
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
Radio.prototype.connect = function () {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
switch (_a.label) {
|
|
120
|
-
case 0:
|
|
121
|
-
this.boundScope.on("change:" + this.key, this.checkSelected, this);
|
|
122
|
-
this.tag.addEventHandler('change', this.getAttributeModifiers(), this.handleEvent.bind(this));
|
|
123
|
-
return [4 /*yield*/, this.checkSelected()];
|
|
124
|
-
case 1:
|
|
125
|
-
_a.sent();
|
|
126
|
-
return [4 /*yield*/, _super.prototype.connect.call(this)];
|
|
127
|
-
case 2:
|
|
128
|
-
_a.sent();
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
Radio.prototype.evaluate = function () {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
return __generator(this, function (_a) {
|
|
137
|
-
switch (_a.label) {
|
|
138
|
-
case 0: return [4 /*yield*/, this.checkSelected()];
|
|
139
|
-
case 1:
|
|
140
|
-
_a.sent();
|
|
141
|
-
return [4 /*yield*/, _super.prototype.evaluate.call(this)];
|
|
142
|
-
case 2:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [2 /*return*/];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
Radio.prototype.handleEvent = function (e) {
|
|
150
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
return __generator(this, function (_a) {
|
|
152
|
-
this.boundScope.set(this.key, this.tag.value);
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
Radio.prototype.checkSelected = function () {
|
|
158
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
159
|
-
var scopeValue;
|
|
160
|
-
return __generator(this, function (_a) {
|
|
161
|
-
scopeValue = this.boundScope.get(this.key);
|
|
162
|
-
this.tag.checked = "" + scopeValue === this.tag.value;
|
|
163
|
-
return [2 /*return*/];
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
Radio.canDefer = false;
|
|
168
|
-
Radio = __decorate([
|
|
169
|
-
Registry_1.Registry.attribute('vsn-radio')
|
|
170
|
-
], Radio);
|
|
171
|
-
return Radio;
|
|
172
|
-
}(Attribute_1.Attribute));
|
|
173
|
-
exports.Radio = Radio;
|
|
174
|
-
//# sourceMappingURL=Radio.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/attributes/Radio.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqC;AACrC,0CAAuC;AAMvC;IAA2B,yBAAS;IAApC;;IA8CA,CAAC;IAzCgB,qBAAK,GAAlB;;;;;;wBACQ,QAAQ,GAAW,IAAI,CAAC,iBAAiB,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;wBAEzF,IAAI;4BACA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;yBAC/C;wBAAC,OAAO,CAAC,EAAE;4BACR,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;4BAC1B,sBAAO;yBACV;wBAED,KAAA,IAAI,CAAA;wBAAO,qBAAM,GAAG,CAAC,MAAM,EAAE,EAAA;;wBAA7B,GAAK,GAAG,GAAG,SAAkB,CAAC;wBAC9B,KAAA,IAAI,CAAA;wBAAc,qBAAM,GAAG,CAAC,QAAQ,EAAE,EAAA;;wBAAtC,GAAK,UAAU,GAAG,SAAoB,CAAC;wBACvC,qBAAM,iBAAM,KAAK,WAAE,EAAA;;wBAAnB,SAAmB,CAAC;;;;;KACvB;IAEY,uBAAO,GAApB;;;;;6BACQ,IAAI,CAAC,GAAG,CAAC,OAAO,EAAhB,wBAAgB;wBAChB,qBAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAA;;wBAA5B,SAA4B,CAAC;;4BACjC,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;IAEY,uBAAO,GAApB;;;;;wBACI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,YAAU,IAAI,CAAC,GAAK,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;wBACnE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC9F,qBAAM,IAAI,CAAC,aAAa,EAAE,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;IAEY,wBAAQ,GAArB;;;;4BACI,qBAAM,IAAI,CAAC,aAAa,EAAE,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,qBAAM,iBAAM,QAAQ,WAAE,EAAA;;wBAAtB,SAAsB,CAAC;;;;;KAC1B;IAEK,2BAAW,GAAjB,UAAkB,CAAC;;;gBACf,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;;;;KACjD;IAEK,6BAAa,GAAnB;;;;gBACU,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,KAAG,UAAY,KAAK,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;;;;KACzD;IA5CsB,cAAQ,GAAY,KAAK,CAAC;IADxC,KAAK;QADjB,mBAAQ,CAAC,SAAS,CAAC,WAAW,CAAC;OACnB,KAAK,CA8CjB;IAAD,YAAC;CAAA,AA9CD,CAA2B,qBAAS,GA8CnC;AA9CY,sBAAK"}
|
package/src/Model/Field.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {IPropertyConfig, Property} from "../Scope/properties/Property";
|
|
2
|
-
import {Registry} from "../Registry";
|
|
3
|
-
|
|
4
|
-
export interface IFieldConfig extends IPropertyConfig {
|
|
5
|
-
validators?: string[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class Field extends Property {
|
|
9
|
-
config: IFieldConfig;
|
|
10
|
-
|
|
11
|
-
validate() {
|
|
12
|
-
const errors = [];
|
|
13
|
-
for(const validatorName of this.config.validators || []) {
|
|
14
|
-
const validator = Registry.instance.validators.getSynchronous(validatorName);
|
|
15
|
-
errors.concat(validator(this.value));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return errors;
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/attributes/Radio.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {Registry} from "../Registry";
|
|
2
|
-
import {Attribute} from "../Attribute";
|
|
3
|
-
import {Scope} from "../Scope";
|
|
4
|
-
import {ScopeReference} from "../Scope/ScopeReference";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@Registry.attribute('vsn-radio')
|
|
8
|
-
export class Radio extends Attribute {
|
|
9
|
-
public static readonly canDefer: boolean = false;
|
|
10
|
-
protected key?: string;
|
|
11
|
-
protected boundScope?: Scope;
|
|
12
|
-
|
|
13
|
-
public async setup() {
|
|
14
|
-
let scopeKey: string = this.getAttributeValue() || this.tag.getRawAttributeValue('name');
|
|
15
|
-
let ref: ScopeReference;
|
|
16
|
-
try {
|
|
17
|
-
ref = this.tag.scope.getReference(scopeKey);
|
|
18
|
-
} catch (e) {
|
|
19
|
-
console.error('error', e);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this.key = await ref.getKey();
|
|
24
|
-
this.boundScope = await ref.getScope();
|
|
25
|
-
await super.setup();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public async extract() {
|
|
29
|
-
if (this.tag.checked)
|
|
30
|
-
await this.handleEvent(null);
|
|
31
|
-
await super.extract();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public async connect() {
|
|
35
|
-
this.boundScope.on(`change:${this.key}`, this.checkSelected, this);
|
|
36
|
-
this.tag.addEventHandler('change', this.getAttributeModifiers(), this.handleEvent.bind(this));
|
|
37
|
-
await this.checkSelected();
|
|
38
|
-
await super.connect();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public async evaluate() {
|
|
42
|
-
await this.checkSelected();
|
|
43
|
-
await super.evaluate();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async handleEvent(e) {
|
|
47
|
-
this.boundScope.set(this.key, this.tag.value);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async checkSelected() {
|
|
51
|
-
const scopeValue = this.boundScope.get(this.key);
|
|
52
|
-
this.tag.checked = `${scopeValue}` === this.tag.value;
|
|
53
|
-
}
|
|
54
|
-
}
|