vsn 0.1.98 → 0.1.99
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/examples/component-slots.html +26 -0
- package/demo/vsn.js +2 -2
- package/dist/AST/ElementAttributeNode.js +5 -5
- package/dist/AST/ElementAttributeNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.js +2 -2
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/ObjectNode.js +1 -1
- package/dist/AST/ObjectNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.js +2 -2
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/Component.js +14 -5
- package/dist/Component.js.map +1 -1
- package/dist/DOM/DOMObject.d.ts +1 -0
- package/dist/DOM/DOMObject.js +7 -0
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/DOM.d.ts +2 -3
- package/dist/DOM.js +68 -31
- package/dist/DOM.js.map +1 -1
- package/dist/Formats.js +4 -1
- package/dist/Formats.js.map +1 -1
- package/dist/Query.d.ts +1 -1
- package/dist/Query.js +2 -2
- package/dist/Query.js.map +1 -1
- package/dist/Scope.d.ts +1 -1
- package/dist/Scope.js +17 -1
- package/dist/Scope.js.map +1 -1
- package/dist/Tag/ShadowRootTag.d.ts +3 -0
- package/dist/Tag/ShadowRootTag.js +28 -0
- package/dist/Tag/ShadowRootTag.js.map +1 -0
- package/dist/Tag/SlotTag.d.ts +3 -0
- package/dist/Tag/SlotTag.js +28 -0
- package/dist/Tag/SlotTag.js.map +1 -0
- package/dist/Tag/SlottedTag.d.ts +3 -0
- package/dist/Tag/SlottedTag.js +28 -0
- package/dist/Tag/SlottedTag.js.map +1 -0
- package/dist/Tag/{List.d.ts → TagList.d.ts} +0 -0
- package/dist/Tag/{List.js → TagList.js} +1 -1
- package/dist/Tag/TagList.js.map +1 -0
- package/dist/Tag.d.ts +5 -2
- package/dist/Tag.js +28 -18
- package/dist/Tag.js.map +1 -1
- package/dist/attributes/List.js +20 -8
- package/dist/attributes/List.js.map +1 -1
- package/dist/attributes/ScopeAttribute.js +14 -12
- package/dist/attributes/ScopeAttribute.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vsn.min.js +3 -0
- package/dist/vsn.min.js.LICENSE.txt +9 -0
- package/package.json +1 -1
- package/src/AST/ElementAttributeNode.ts +1 -1
- package/src/AST/ElementStyleNode.ts +1 -1
- package/src/AST/ObjectNode.ts +1 -1
- package/src/AST/ScopeMemberNode.ts +1 -1
- package/src/Component.ts +10 -3
- package/src/DOM/DOMObject.ts +4 -0
- package/src/DOM.ts +28 -5
- package/src/Formats.ts +4 -1
- package/src/Query.ts +1 -1
- package/src/Scope.ts +14 -1
- package/src/Tag/ShadowRootTag.ts +5 -0
- package/src/Tag/SlotTag.ts +5 -0
- package/src/Tag/SlottedTag.ts +5 -0
- package/src/Tag/{List.ts → TagList.ts} +0 -0
- package/src/Tag.ts +16 -18
- package/src/attributes/List.ts +24 -7
- package/src/attributes/ScopeAttribute.ts +12 -8
- package/src/version.ts +1 -1
- package/test/AST/ClassNode.spec.ts +1 -1
- package/test/Tag/TagList.spec.ts +1 -1
- package/test/attributes/ListItem.spec.ts +2 -2
- package/dist/Tag/List.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
|
4
|
+
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
5
|
+
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
6
|
+
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
7
|
+
* Code distributed by Google as part of the polymer project is also
|
|
8
|
+
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
9
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Scope} from "../Scope";
|
|
2
2
|
import {DOM} from "../DOM";
|
|
3
3
|
import {Tag} from "../Tag";
|
|
4
|
-
import {TagList} from "../Tag/
|
|
4
|
+
import {TagList} from "../Tag/TagList";
|
|
5
5
|
import {TreeNode} from "../AST";
|
|
6
6
|
import {Node} from "./Node";
|
|
7
7
|
import {ElementQueryNode} from "./ElementQueryNode";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Scope} from "../Scope";
|
|
2
2
|
import {DOM} from "../DOM";
|
|
3
3
|
import {Tag} from "../Tag";
|
|
4
|
-
import {TagList} from "../Tag/
|
|
4
|
+
import {TagList} from "../Tag/TagList";
|
|
5
5
|
import {TreeNode} from "../AST";
|
|
6
6
|
import {Node} from "./Node";
|
|
7
7
|
import {ElementQueryNode} from "./ElementQueryNode";
|
package/src/AST/ObjectNode.ts
CHANGED
|
@@ -21,7 +21,7 @@ export class ObjectNode extends Node implements TreeNode {
|
|
|
21
21
|
for (let i = 0; i < this.values.length; i++) {
|
|
22
22
|
const key = this.keys[i];
|
|
23
23
|
const val = this.values[i];
|
|
24
|
-
obj.set(await key.evaluate(scope, dom, tag), await val.evaluate(scope, dom, tag));
|
|
24
|
+
obj.set(await key.evaluate(scope, dom, tag), await val.evaluate(scope, dom, tag), true);
|
|
25
25
|
}
|
|
26
26
|
return obj;
|
|
27
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Scope} from "../Scope";
|
|
2
2
|
import {DOM} from "../DOM";
|
|
3
3
|
import {Tag} from "../Tag";
|
|
4
|
-
import {TagList} from "../Tag/
|
|
4
|
+
import {TagList} from "../Tag/TagList";
|
|
5
5
|
import {DOMObject} from "../DOM/DOMObject";
|
|
6
6
|
import {TreeNode} from "../AST";
|
|
7
7
|
import {Node} from "./Node";
|
package/src/Component.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {Registry} from "./Registry";
|
|
2
2
|
import {DOM} from "./DOM";
|
|
3
|
+
import {SlotTag} from "./Tag/SlotTag";
|
|
4
|
+
import {SlottedTag} from "./Tag/SlottedTag";
|
|
3
5
|
|
|
4
6
|
export class Component extends HTMLElement {
|
|
5
7
|
protected readonly shadow: ShadowRoot;
|
|
@@ -21,14 +23,19 @@ export class Component extends HTMLElement {
|
|
|
21
23
|
this.setAttribute('vsn-ref', '');
|
|
22
24
|
|
|
23
25
|
this.shadow.appendChild(template.content.cloneNode(true));
|
|
24
|
-
this.shadow.querySelectorAll('slot').forEach(slot => {
|
|
26
|
+
this.shadow.querySelectorAll('slot').forEach((slot) => {
|
|
27
|
+
const slotTagPromise = DOM.instance.buildTag(slot,false, SlotTag);
|
|
25
28
|
slot.addEventListener('slotchange', async (e) => {
|
|
26
29
|
for (const child of slot.assignedNodes()) {
|
|
27
|
-
const t = await DOM.instance.
|
|
28
|
-
t?.slotted(slot);
|
|
30
|
+
const t = await DOM.instance.buildTag(child as HTMLElement, false, SlottedTag);
|
|
31
|
+
await t?.slotted(slot);
|
|
29
32
|
}
|
|
33
|
+
slotTagPromise.then((slotTag) => {
|
|
34
|
+
slotTag.buildAttributes();
|
|
35
|
+
});
|
|
30
36
|
});
|
|
31
37
|
});
|
|
38
|
+
|
|
32
39
|
DOM.instance.buildFrom(this.shadow);
|
|
33
40
|
}
|
|
34
41
|
}
|
package/src/DOM/DOMObject.ts
CHANGED
|
@@ -31,6 +31,10 @@ export abstract class DOMObject extends EventDispatcher {
|
|
|
31
31
|
return this.element instanceof HTMLSlotElement;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
public get isSlotted(): boolean {
|
|
35
|
+
return this.element.hasAttribute('slot');
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
public get scope(): Scope {
|
|
35
39
|
if (!!this._scope)
|
|
36
40
|
return this._scope;
|
package/src/DOM.ts
CHANGED
|
@@ -2,13 +2,15 @@ import {Tag} from "./Tag";
|
|
|
2
2
|
import {ElementHelper} from "./helpers/ElementHelper";
|
|
3
3
|
import {Configuration} from "./Configuration";
|
|
4
4
|
import {Tree} from "./AST";
|
|
5
|
-
import {TagList} from "./Tag/
|
|
5
|
+
import {TagList} from "./Tag/TagList";
|
|
6
6
|
import {WrappedWindow} from "./DOM/WrappedWindow";
|
|
7
7
|
import {WrappedDocument} from "./DOM/WrappedDocument";
|
|
8
8
|
import {Scope} from "./Scope";
|
|
9
9
|
import {EventDispatcher} from "./EventDispatcher";
|
|
10
10
|
import {ClassNode} from "./AST/ClassNode";
|
|
11
11
|
import {Registry} from "./Registry";
|
|
12
|
+
import {SlotTag} from "./Tag/SlotTag";
|
|
13
|
+
import {SlottedTag} from "./Tag/SlottedTag";
|
|
12
14
|
|
|
13
15
|
export enum EQuerySelectDirection {
|
|
14
16
|
ALL,
|
|
@@ -27,7 +29,6 @@ export class DOM extends EventDispatcher {
|
|
|
27
29
|
protected window: WrappedWindow;
|
|
28
30
|
protected document: WrappedDocument;
|
|
29
31
|
protected _built: boolean = false;
|
|
30
|
-
public selected: Tag;
|
|
31
32
|
|
|
32
33
|
constructor(
|
|
33
34
|
protected rootElement: Document,
|
|
@@ -192,6 +193,10 @@ export class DOM extends EventDispatcher {
|
|
|
192
193
|
async discover(ele: HTMLElement, forComponent: boolean = false): Promise<HTMLElement[]> {
|
|
193
194
|
const discovered: HTMLElement[] = [];
|
|
194
195
|
const checkElement = (e: HTMLElement): boolean => {
|
|
196
|
+
if (Registry.instance.components.has(e?.tagName?.toLowerCase())) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
195
200
|
if (ElementHelper.hasVisionAttribute(e)) {
|
|
196
201
|
if (
|
|
197
202
|
(!forComponent && e.hasAttribute('slot'))
|
|
@@ -216,9 +221,14 @@ export class DOM extends EventDispatcher {
|
|
|
216
221
|
return discovered;
|
|
217
222
|
}
|
|
218
223
|
|
|
219
|
-
async buildTag(element: HTMLElement, returnExisting: boolean = false): Promise<Tag> {
|
|
224
|
+
async buildTag(element: HTMLElement, returnExisting: boolean = false, cls: any = Tag): Promise<Tag> {
|
|
220
225
|
if (element[Tag.TaggedVariable]) return returnExisting ? element[Tag.TaggedVariable] : null;
|
|
221
|
-
|
|
226
|
+
if (element.tagName.toLowerCase() === 'slot')
|
|
227
|
+
cls = SlotTag;
|
|
228
|
+
else if (element.hasAttribute('slot'))
|
|
229
|
+
cls = SlottedTag;
|
|
230
|
+
|
|
231
|
+
const tag: Tag = new cls(element, this);
|
|
222
232
|
this.tags.push(tag);
|
|
223
233
|
return tag;
|
|
224
234
|
}
|
|
@@ -261,6 +271,20 @@ export class DOM extends EventDispatcher {
|
|
|
261
271
|
document.ondragover = (e) => e.cancelable && e.preventDefault(); // Allow dragging over document
|
|
262
272
|
}
|
|
263
273
|
|
|
274
|
+
// Setup components first
|
|
275
|
+
const templateNodes = this.querySelectorElement(ele, 'template');
|
|
276
|
+
const components: Tag[] = [];
|
|
277
|
+
for (const n of Array.from(templateNodes) as HTMLElement[]) {
|
|
278
|
+
if (!ElementHelper.hasVisionAttribute(n))
|
|
279
|
+
continue;
|
|
280
|
+
|
|
281
|
+
const tag = await this.buildTag(n);
|
|
282
|
+
if (tag)
|
|
283
|
+
components.push(tag);
|
|
284
|
+
}
|
|
285
|
+
if (components.length)
|
|
286
|
+
await this.setupTags(components);
|
|
287
|
+
|
|
264
288
|
// Create tags for each html element with a vsn-attribute
|
|
265
289
|
const newTags: Tag[] = [];
|
|
266
290
|
const toBuild: HTMLElement[] = await this.discover(ele, forComponent);
|
|
@@ -270,7 +294,6 @@ export class DOM extends EventDispatcher {
|
|
|
270
294
|
if (tag)
|
|
271
295
|
newTags.push(tag);
|
|
272
296
|
}
|
|
273
|
-
|
|
274
297
|
if (isRoot)
|
|
275
298
|
this._root = await this.getTagForElement(document.body);
|
|
276
299
|
|
package/src/Formats.ts
CHANGED
|
@@ -20,7 +20,10 @@ export class Formats {
|
|
|
20
20
|
setup();
|
|
21
21
|
}
|
|
22
22
|
value = `${value}`.replace(/[^0-9.]+/, '');
|
|
23
|
-
|
|
23
|
+
value = parseFloat(value);
|
|
24
|
+
if (isNaN(value))
|
|
25
|
+
return '';
|
|
26
|
+
return Formats.CurrencyFormatter.format(value);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
@Registry.format('date')
|
package/src/Query.ts
CHANGED
package/src/Scope.ts
CHANGED
|
@@ -94,7 +94,20 @@ export class Scope extends EventDispatcher {
|
|
|
94
94
|
return value;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
set(key: string, value: any) {
|
|
97
|
+
set(key: string, value: any, detectType: boolean = false): void {
|
|
98
|
+
if (detectType) {
|
|
99
|
+
const type = typeof value;
|
|
100
|
+
if (type === 'number') {
|
|
101
|
+
if (value % 1 === 0)
|
|
102
|
+
this.setType(key, 'integer');
|
|
103
|
+
else
|
|
104
|
+
this.setType(key, 'float');
|
|
105
|
+
} else if (type === 'string') {
|
|
106
|
+
this.setType(key, 'string');
|
|
107
|
+
} else if (type === 'boolean') {
|
|
108
|
+
this.setType(key, 'boolean');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
98
111
|
if (!this._data.hasProperty(key))
|
|
99
112
|
this._data.createProperty(key);
|
|
100
113
|
this._data[key] = value;
|
|
File without changes
|
package/src/Tag.ts
CHANGED
|
@@ -28,6 +28,7 @@ export class Tag extends DOMObject {
|
|
|
28
28
|
protected _state: TagState;
|
|
29
29
|
protected _meta: { [key: string]: any; };
|
|
30
30
|
protected attributes: Attribute[];
|
|
31
|
+
protected attributeMap: { [key: string]: Attribute; };
|
|
31
32
|
protected _nonDeferredAttributes: Attribute[] = [];
|
|
32
33
|
protected _parentTag: Tag;
|
|
33
34
|
protected _children: Tag[] = [];
|
|
@@ -60,14 +61,10 @@ export class Tag extends DOMObject {
|
|
|
60
61
|
this.rawAttributes = {};
|
|
61
62
|
this.parsedAttributes = {};
|
|
62
63
|
this.attributes = [];
|
|
64
|
+
this.attributeMap = {};
|
|
63
65
|
this.onEventHandlers = {};
|
|
64
66
|
this.analyzeElementAttributes();
|
|
65
67
|
this._state = TagState.Instantiated;
|
|
66
|
-
if (this.hasAttribute('slot')) {
|
|
67
|
-
this.addEventHandler('slotted',[], (e) => {
|
|
68
|
-
console.log('slot change', e, this.element.assignedSlot);
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
public get meta() {
|
|
@@ -76,9 +73,11 @@ export class Tag extends DOMObject {
|
|
|
76
73
|
return this._meta;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
public slotted(slot: HTMLSlotElement) {
|
|
76
|
+
public async slotted(slot: HTMLSlotElement) {
|
|
80
77
|
this.slot = slot;
|
|
81
|
-
|
|
78
|
+
this.parentTag = await this.dom.getTagForElement(slot);
|
|
79
|
+
await this.dom.setupTags([this]);
|
|
80
|
+
await this.dom.buildFrom(this.element, false, true);
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
protected onAttributeStateChange(event) {
|
|
@@ -439,7 +438,6 @@ export class Tag extends DOMObject {
|
|
|
439
438
|
public async buildAttributes() {
|
|
440
439
|
let requiresScope = false;
|
|
441
440
|
let defer: boolean = false;
|
|
442
|
-
this.attributes.length = 0;
|
|
443
441
|
const isMobile: boolean = VisionHelper.isMobile();
|
|
444
442
|
if (this.element.offsetParent === null ||
|
|
445
443
|
this.hasAttribute('hidden') ||
|
|
@@ -452,17 +450,15 @@ export class Tag extends DOMObject {
|
|
|
452
450
|
const slot: Tag = this.isSlot ? this : null;
|
|
453
451
|
for (const tag of tags) {
|
|
454
452
|
for (let attr in this.rawAttributes) {
|
|
455
|
-
if (
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
453
|
+
if (tag.attributeMap[attr])
|
|
454
|
+
continue;
|
|
455
|
+
|
|
456
|
+
if (this.hasModifier(attr, 'mobile') && !isMobile)
|
|
457
|
+
continue;
|
|
460
458
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
}
|
|
459
|
+
|
|
460
|
+
if (this.hasModifier(attr, 'desktop') && isMobile)
|
|
461
|
+
continue;
|
|
466
462
|
|
|
467
463
|
const attrClass = await this.getAttributeClass(attr);
|
|
468
464
|
if (attrClass) {
|
|
@@ -470,7 +466,9 @@ export class Tag extends DOMObject {
|
|
|
470
466
|
requiresScope = true;
|
|
471
467
|
|
|
472
468
|
const attrObj = attrClass.create(tag, attr, attrClass, slot);
|
|
469
|
+
|
|
473
470
|
tag.attributes.push(attrObj);
|
|
471
|
+
tag.attributeMap[attr] = attrObj;
|
|
474
472
|
if (defer && attrClass.canDefer) {
|
|
475
473
|
await attrObj.defer();
|
|
476
474
|
tag.deferredAttributes.push(attrObj);
|
package/src/attributes/List.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {ElementHelper} from "../helpers/ElementHelper";
|
|
|
5
5
|
import {Registry} from "../Registry";
|
|
6
6
|
import {DOM} from "../DOM";
|
|
7
7
|
import {Scope} from "../Scope";
|
|
8
|
+
import {ScopeData} from "../Scope/ScopeData";
|
|
8
9
|
|
|
9
10
|
@Registry.attribute('vsn-list')
|
|
10
11
|
export class List extends Attribute {
|
|
@@ -146,6 +147,13 @@ export class List extends Attribute {
|
|
|
146
147
|
}
|
|
147
148
|
delete element[Tag.TaggedVariable];
|
|
148
149
|
|
|
150
|
+
// Collect raw data
|
|
151
|
+
let data;
|
|
152
|
+
if (obj instanceof ScopeData)
|
|
153
|
+
data = obj.getData();
|
|
154
|
+
else
|
|
155
|
+
data = Object.assign({}, obj);
|
|
156
|
+
|
|
149
157
|
// Setup new tag
|
|
150
158
|
const tag = await this.tag.dom.buildTag(element, true);
|
|
151
159
|
await this.setupTagScope(tag, obj);
|
|
@@ -154,6 +162,13 @@ export class List extends Attribute {
|
|
|
154
162
|
this.tag.element.appendChild(element);
|
|
155
163
|
await this.tag.dom.setupTags([tag]);
|
|
156
164
|
await this.tag.dom.buildFrom(this.tag.element);
|
|
165
|
+
|
|
166
|
+
// Make sure we're using the correct data (Template may have vsn-bind values that are not desired)
|
|
167
|
+
const itemScope = tag.scope.get(this.listItemName);
|
|
168
|
+
if (itemScope instanceof Scope && data) {
|
|
169
|
+
itemScope.data.setData(data);
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
this.tags.push(tag);
|
|
158
173
|
this.tag.dispatch('add', obj);
|
|
159
174
|
}
|
|
@@ -163,26 +178,28 @@ export class List extends Attribute {
|
|
|
163
178
|
return;
|
|
164
179
|
|
|
165
180
|
tag.createScope(true);
|
|
181
|
+
const itemScope = new Scope(tag.scope);
|
|
166
182
|
|
|
167
|
-
// Setup new scope & class, if defined
|
|
183
|
+
// Setup new scope & model class, if defined
|
|
168
184
|
const modelName: string = this.listItemModel;
|
|
169
185
|
let cls;
|
|
170
186
|
if (modelName)
|
|
171
187
|
cls = await Registry.instance.models.get(modelName);
|
|
172
188
|
|
|
173
189
|
if (cls) {
|
|
174
|
-
if (!obj || !(obj instanceof cls))
|
|
190
|
+
if (!obj || !(obj instanceof cls)) {
|
|
175
191
|
obj = new cls(obj);
|
|
192
|
+
}
|
|
176
193
|
}
|
|
177
194
|
|
|
178
195
|
// Check if the class is set up already
|
|
179
|
-
if (!cls || (!(
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
196
|
+
if (!cls || (!(itemScope.data instanceof cls) && !(itemScope.wrapped instanceof cls))) {
|
|
197
|
+
if (itemScope.wrapped)
|
|
198
|
+
itemScope.unwrap();
|
|
199
|
+
itemScope.wrap(obj, true, true);
|
|
183
200
|
}
|
|
184
201
|
|
|
185
|
-
tag.scope.set(this.listItemName,
|
|
202
|
+
tag.scope.set(this.listItemName, itemScope);
|
|
186
203
|
tag.meta[List.MetaItemSetupFlag] = true;
|
|
187
204
|
}
|
|
188
205
|
}
|
|
@@ -20,17 +20,21 @@ export class ScopeAttribute extends Attribute {
|
|
|
20
20
|
|
|
21
21
|
public async extract() {
|
|
22
22
|
if (this.tree) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const binding = this.getAttributeBinding();
|
|
24
|
+
|
|
25
|
+
const scope = await this.tree.evaluate(this.tag.scope, this.tag.dom, this.tag);
|
|
26
|
+
if (!(scope instanceof Scope)) {
|
|
27
|
+
throw new Error(`vsn-scope value must be an object, got ${typeof scope}`);
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
if (binding) {
|
|
31
|
+
this.tag.scope.set(binding, scope);
|
|
32
|
+
} else {
|
|
33
|
+
for (const key of scope.data.keys) {
|
|
34
|
+
this.tag.scope.set(key, scope.data[key]);
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
|
-
const binding = this.getAttributeBinding();
|
|
32
|
-
if (binding)
|
|
33
|
-
this.tag.scope.parentScope.set(binding, this.tag.scope);
|
|
34
38
|
await super.extract();
|
|
35
39
|
}
|
|
36
40
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.99';
|
|
2
2
|
|
package/test/Tag/TagList.spec.ts
CHANGED
|
@@ -72,7 +72,7 @@ describe('ListItem', () => {
|
|
|
72
72
|
list.on('add', () => {
|
|
73
73
|
const listItem = listAttr.tags[0];
|
|
74
74
|
|
|
75
|
-
expect(listItem.scope.data instanceof ListItemSpecTestItem).toBeTrue();
|
|
75
|
+
expect(listItem.scope.get('item').data instanceof ListItemSpecTestItem).toBeTrue();
|
|
76
76
|
expect(controller.items.length).toBe(1);
|
|
77
77
|
expect(controller.items[0] instanceof ListItemSpecTestItem).toBeTrue();
|
|
78
78
|
|
|
@@ -95,7 +95,7 @@ describe('ListItem', () => {
|
|
|
95
95
|
const dom = new DOM(document);
|
|
96
96
|
dom.once('built', async () => {
|
|
97
97
|
const listItem = await dom.getTagForElement(document.getElementById('test-item'));
|
|
98
|
-
expect(listItem.scope.get('testing')).toBe(1);
|
|
98
|
+
expect(listItem.scope.get('item').get('testing')).toBe(1);
|
|
99
99
|
done();
|
|
100
100
|
});
|
|
101
101
|
});
|
package/dist/Tag/List.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/Tag/List.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAqD;AAIrD;IAA6B,2BAAgB;IACzC;QAAY,eAAqB;aAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;YAArB,0BAAqB;;QAAjC,+BACa,KAAK,UAEjB;QADG,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;;IACnD,CAAC;IAED,sBAAI,0BAAK;aAAT;YACI,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QACxB,CAAC;;;OAAA;IAED,sBAAI,6BAAQ;aAAZ;YACI,OAAO,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS,CAAC,CAAC;QACpC,CAAC;;;OAAA;IAED,sBAAI,0BAAK;aAAT;YACI,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;;;OAAA;IAED,sBAAI,yBAAI;aAAR;YACI,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;;;OAAA;IAED,qBAAG,GAAH,UAAI,KAAa;QACb,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAhB,CAAgB,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,6BAAW,GAAX,UAAY,SAAS;QACjB,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,EAArC,CAAqC,CAAC,CAAA;QACxD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,0BAAQ,GAAR,UAAS,SAAS;QACd,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAlC,CAAkC,CAAC,CAAA;QACrD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,qBAAG,GAAH,UAAI,QAAQ,EAAE,KAAK;QACf,IAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,UAAA,CAAC;YAC5C,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QAC3C,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,EAApC,CAAoC,CAAC,CAAA;QACvD,OAAO,IAAI,CAAA;IACf,CAAC;IACL,cAAC;AAAD,CAAC,AA5CD,CAA6B,KAAK,GA4CjC;AA5CY,0BAAO;AA8CpB,IAAI,2BAAY,CAAC,aAAa,IAAI,2BAAY,CAAC,MAAM;IACjD,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC"}
|