vsn 0.1.37 → 0.1.40
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/vsn.js +1 -1
- package/dist/Scope/ScopeDataAbstract.d.ts +1 -0
- package/dist/Scope/ScopeDataAbstract.js +15 -0
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope/properties/Property.d.ts +1 -0
- package/dist/Scope/properties/Property.js +12 -2
- package/dist/Scope/properties/Property.js.map +1 -1
- package/dist/Scope.d.ts +2 -1
- package/dist/Scope.js +24 -17
- package/dist/Scope.js.map +1 -1
- package/dist/Tag.d.ts +4 -2
- package/dist/Tag.js +48 -3
- package/dist/Tag.js.map +1 -1
- package/package.json +1 -1
- package/src/Scope/ScopeDataAbstract.ts +11 -0
- package/src/Scope/properties/Property.ts +12 -1
- package/src/Scope.ts +22 -18
- package/src/Tag.ts +41 -6
package/src/Tag.ts
CHANGED
|
@@ -168,17 +168,35 @@ export class Tag extends DOMObject {
|
|
|
168
168
|
return this.inputTags.indexOf(this.element.tagName.toLowerCase()) > -1;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
get isSelect(): boolean {
|
|
172
|
+
return this.element.tagName.toLowerCase() === 'select';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
get isMultipleSelect(): boolean {
|
|
176
|
+
return this.isSelect && this.element.hasAttribute('multiple');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
set value(value: string | string[]) {
|
|
172
180
|
if (this.isInput) {
|
|
173
|
-
this.
|
|
174
|
-
|
|
181
|
+
if (this.isMultipleSelect) {
|
|
182
|
+
for (const option of Array.from((this.element as HTMLSelectElement).options)) {
|
|
183
|
+
option.selected = value.indexOf(option.value) > -1;
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
this.element.setAttribute('value', value as string);
|
|
187
|
+
(this.element as any).value = value;
|
|
188
|
+
}
|
|
189
|
+
|
|
175
190
|
} else {
|
|
176
|
-
this.element.innerText = value;
|
|
191
|
+
this.element.innerText = value as string;
|
|
177
192
|
}
|
|
178
193
|
}
|
|
179
194
|
|
|
180
|
-
get value(): string {
|
|
195
|
+
get value(): string | string[] {
|
|
181
196
|
if (this.isInput) {
|
|
197
|
+
if (this.isMultipleSelect) {
|
|
198
|
+
return Array.from((this.element as HTMLSelectElement).options).filter((o) => o.selected).map((o) => o.value);
|
|
199
|
+
}
|
|
182
200
|
return (this.element as any).value;
|
|
183
201
|
} else {
|
|
184
202
|
return this.element.textContent;
|
|
@@ -253,6 +271,7 @@ export class Tag extends DOMObject {
|
|
|
253
271
|
|
|
254
272
|
if (obj instanceof Controller) {
|
|
255
273
|
obj.init(this.scope, this, this.element);
|
|
274
|
+
this.controller = obj;
|
|
256
275
|
} else {
|
|
257
276
|
obj['$scope'] = this.scope;
|
|
258
277
|
obj['$tag'] = this;
|
|
@@ -407,7 +426,23 @@ export class Tag extends DOMObject {
|
|
|
407
426
|
}
|
|
408
427
|
|
|
409
428
|
public inputMutation(e) {
|
|
410
|
-
this.
|
|
429
|
+
if (this.isSelect) {
|
|
430
|
+
const selected = (this.element as HTMLSelectElement).selectedOptions;
|
|
431
|
+
const values = [];
|
|
432
|
+
for (let i = 0; i < selected.length; i++) {
|
|
433
|
+
values.push(selected[i].value);
|
|
434
|
+
}
|
|
435
|
+
for (const option of Array.from((this.element as HTMLSelectElement).options)) {
|
|
436
|
+
if (values.indexOf(option.value) > -1) {
|
|
437
|
+
option.setAttribute('selected', '');
|
|
438
|
+
} else {
|
|
439
|
+
option.removeAttribute('selected');
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
this.element.setAttribute('value', values.join(','));
|
|
443
|
+
} else {
|
|
444
|
+
this.element.setAttribute('value', e.target.value);
|
|
445
|
+
}
|
|
411
446
|
}
|
|
412
447
|
|
|
413
448
|
public finalize(): void {
|