vsn 0.1.67 → 0.1.68

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.67",
3
+ "version": "0.1.68",
4
4
  "description": "SEO Friendly Javascript/Typescript Framework",
5
5
  "keywords": [
6
6
  "framework",
@@ -11,6 +11,7 @@ export class ClassNode extends Node implements TreeNode {
11
11
  public static readonly classes: {[name: string]: ClassNode} = {};
12
12
  protected requiresPrep: boolean = true;
13
13
  public readonly classScope: Scope = new Scope();
14
+ protected _ready: boolean = false;
14
15
 
15
16
  constructor(
16
17
  public readonly name: string,
@@ -32,6 +33,10 @@ export class ClassNode extends Node implements TreeNode {
32
33
  ClassNode.classes[this.name] = this;
33
34
  await this.block.prepare(this.classScope, dom, tag, meta);
34
35
  Registry.class(this);
36
+
37
+ for (const element of Array.from(dom.querySelectorAll(`.${this.name}`))) {
38
+ await ClassNode.checkForClassChanges(element as HTMLElement, dom, element[Tag.TaggedVariable] || null);
39
+ }
35
40
  }
36
41
 
37
42
  public async prepareTag(tag: Tag, dom: DOM, hasConstructor: boolean | null = null) {
@@ -45,14 +50,6 @@ export class ClassNode extends Node implements TreeNode {
45
50
  const fnc = this.classScope.get('construct');
46
51
  (await fnc.evaluate(tag.scope, dom, tag))();
47
52
  }
48
- /*
49
- for (const key of this.classScope.keys) {
50
- if (this.classScope.get(key) instanceof OnNode) {
51
- const on = this.classScope.get(key) as OnNode;
52
- tag.addEventHandler(on.name, [], await on.getFunction(tag.scope, dom, tag), on);
53
- }
54
- }
55
- */
56
53
  tag.preppedClasses.push(this.name);
57
54
  }
58
55
 
@@ -93,7 +90,8 @@ export class ClassNode extends Node implements TreeNode {
93
90
  public static async checkForClassChanges(element: HTMLElement, dom: DOM, tag: Tag = null) {
94
91
  const classes: string[] = Array.from(element.classList);
95
92
  let addedClasses: string[] = classes.filter(c => Registry.instance.classes.has(c));
96
- let removedClasses: string[] = [];
93
+ let removedClasses: string[];
94
+
97
95
  if (!tag) {
98
96
  tag = await dom.getTagForElement(element, true);
99
97
  }
package/src/Tag.ts CHANGED
@@ -21,9 +21,8 @@ export enum TagState {
21
21
  Built,
22
22
  }
23
23
 
24
- export const TaggedVariable:string = '_vsn_tag';
25
-
26
24
  export class Tag extends DOMObject {
25
+ public static readonly TaggedVariable: string = '_vsn_tag';
27
26
  public readonly rawAttributes: { [key: string]: string; };
28
27
  public readonly parsedAttributes: { [key: string]: string[]; };
29
28
  public readonly deferredAttributes: Attribute[] = [];
@@ -58,7 +57,7 @@ export class Tag extends DOMObject {
58
57
  ...props
59
58
  ) {
60
59
  super(element, props);
61
- element[TaggedVariable] = this;
60
+ element[Tag.TaggedVariable] = this;
62
61
  this.rawAttributes = {};
63
62
  this.parsedAttributes = {};
64
63
  this.attributes = [];
@@ -240,9 +239,9 @@ export class Tag extends DOMObject {
240
239
  let parentElement: HTMLElement = this.element.parentElement as HTMLElement;
241
240
  let foundParent = false;
242
241
  while (parentElement) {
243
- if (parentElement[TaggedVariable]) {
242
+ if (parentElement[Tag.TaggedVariable]) {
244
243
  foundParent = true;
245
- this.parentTag = parentElement[TaggedVariable];
244
+ this.parentTag = parentElement[Tag.TaggedVariable];
246
245
  break;
247
246
  }
248
247
 
@@ -2,11 +2,6 @@ import {ClassNode} from "../AST/ClassNode";
2
2
 
3
3
  export class ElementHelper {
4
4
  public static hasVisionAttribute(element: HTMLElement | Element, testAttr: string = 'vsn-'): boolean {
5
- for (const cls of Array.from(element.classList)) {
6
- if (ClassNode.isClass(cls))
7
- return true;
8
- }
9
-
10
5
  if (!element.attributes || element.attributes.length <= 0) return false;
11
6
  for (let i: number = 0; i < element.attributes.length; i++) {
12
7
  const attr: Attr = element.attributes[i];
@@ -16,6 +11,12 @@ export class ElementHelper {
16
11
  }
17
12
  }
18
13
 
14
+ for (const cls of Array.from(element.classList)) {
15
+ if (ClassNode.isClass(cls)) {
16
+ return true;
17
+ }
18
+ }
19
+
19
20
  return false;
20
21
  }
21
22