vsn 0.1.102 → 0.1.105

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vsn",
3
- "version": "0.1.102",
3
+ "version": "0.1.105",
4
4
  "description": "SEO Friendly Javascript/Typescript Framework",
5
5
  "keywords": [
6
6
  "framework",
package/src/DOM.ts CHANGED
@@ -269,6 +269,9 @@ export class DOM extends EventDispatcher {
269
269
  if (isRoot) {
270
270
  document.body.setAttribute('vsn-root', '');
271
271
  document.ondragover = (e) => e.cancelable && e.preventDefault(); // Allow dragging over document
272
+ this._root = await this.buildTag(document.body, true);
273
+ this._root.createScope(true);
274
+ await this.setupTags([this._root]);
272
275
  }
273
276
 
274
277
  // Setup components first
@@ -294,8 +297,6 @@ export class DOM extends EventDispatcher {
294
297
  if (tag)
295
298
  newTags.push(tag);
296
299
  }
297
- if (isRoot)
298
- this._root = await this.getTagForElement(document.body);
299
300
 
300
301
  await this.setupTags(newTags);
301
302
 
@@ -370,7 +371,7 @@ export class DOM extends EventDispatcher {
370
371
  await this.resetBranch(t);
371
372
  }
372
373
 
373
- if (tag && tag.uniqueScope && tag.parentTag) {
374
+ if (tag && tag.parentTag && tag.uniqueScope) {
374
375
  tag.scope.parentScope = tag.parentTag.scope;
375
376
  }
376
377
  }
package/src/Tag.ts CHANGED
@@ -561,6 +561,7 @@ export class Tag extends DOMObject {
561
561
  public async finalize() {
562
562
  this._state = TagState.Built;
563
563
  this.callOnWrapped('$built', this, this.scope, this.element);
564
+ this.dispatch('$built', this);
564
565
  VisionHelper.nice(this.setupDeferredAttributes.bind(this));
565
566
  }
566
567
 
@@ -9,7 +9,6 @@ export class If extends Attribute {
9
9
 
10
10
  public async compile() {
11
11
  const statement: string = this.getAttributeValue();
12
- console.log('if statement for', this.tag.element, statement);
13
12
  this.tree = new Tree(statement);
14
13
  await this.tree.prepare(this.tag.scope, this.tag.dom, this.tag);
15
14
  await super.compile();
@@ -34,10 +33,8 @@ export class If extends Attribute {
34
33
  const result: boolean = await this.tree.evaluate(this.tag.scope, this.tag.dom, this.tag);
35
34
  if (result) {
36
35
  this.tag.show();
37
- console.log('show', this.tag.element);
38
36
  } else {
39
37
  this.tag.hide();
40
- console.log('hide', this.tag.element);
41
38
  }
42
39
  }
43
40
  }
@@ -99,7 +99,8 @@ export class List extends Attribute {
99
99
  const tag: Tag = await this.tag.dom.getTagForElement(element);
100
100
  if (tag) {
101
101
  this.tags.push(tag);
102
- this.items.push(tag.scope.wrapped || tag.scope);
102
+ let listModel = tag.scope.get(this.listItemName);
103
+ this.items.push(listModel?.wrapped || listModel || tag.scope.wrapped || tag.scope);
103
104
  }
104
105
  }
105
106
 
@@ -189,6 +190,10 @@ export class List extends Attribute {
189
190
  if (cls) {
190
191
  if (!obj || !(obj instanceof cls)) {
191
192
  obj = new cls(obj);
193
+ this.tag.once('$built', () => {
194
+ if (obj['$built'])
195
+ obj['$built'](this.tag, this.tag.scope, this.tag.element);
196
+ });
192
197
  }
193
198
  }
194
199
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.1.102';
1
+ export const VERSION = '0.1.105';
2
2