vsn 0.1.136 → 0.1.138

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.
Files changed (37) hide show
  1. package/demo/resources/xhr-memory-leak-test.html +1 -0
  2. package/demo/vsn.js +2 -2
  3. package/dist/Attribute.d.ts +3 -1
  4. package/dist/Attribute.js +10 -0
  5. package/dist/Attribute.js.map +1 -1
  6. package/dist/Scope.js +30 -13
  7. package/dist/Scope.js.map +1 -1
  8. package/dist/Tag.d.ts +1 -1
  9. package/dist/Tag.js +6 -0
  10. package/dist/Tag.js.map +1 -1
  11. package/dist/attributes/Bind.d.ts +1 -0
  12. package/dist/attributes/Bind.js +14 -0
  13. package/dist/attributes/Bind.js.map +1 -1
  14. package/dist/attributes/ScopeChange.d.ts +1 -0
  15. package/dist/attributes/ScopeChange.js +23 -0
  16. package/dist/attributes/ScopeChange.js.map +1 -1
  17. package/dist/attributes/StandardAttribute.d.ts +1 -0
  18. package/dist/attributes/StandardAttribute.js +15 -1
  19. package/dist/attributes/StandardAttribute.js.map +1 -1
  20. package/dist/attributes/StyleAttribute.d.ts +1 -0
  21. package/dist/attributes/StyleAttribute.js +14 -0
  22. package/dist/attributes/StyleAttribute.js.map +1 -1
  23. package/dist/attributes/StyleVarAttribute.d.ts +1 -0
  24. package/dist/attributes/StyleVarAttribute.js +14 -0
  25. package/dist/attributes/StyleVarAttribute.js.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/dist/version.js +1 -1
  28. package/package.json +1 -1
  29. package/src/Attribute.ts +7 -1
  30. package/src/Scope.ts +9 -1
  31. package/src/Tag.ts +4 -0
  32. package/src/attributes/Bind.ts +5 -0
  33. package/src/attributes/ScopeChange.ts +7 -0
  34. package/src/attributes/StandardAttribute.ts +6 -1
  35. package/src/attributes/StyleAttribute.ts +5 -0
  36. package/src/attributes/StyleVarAttribute.ts +5 -0
  37. package/src/version.ts +1 -1
@@ -97,6 +97,20 @@ var StyleVarAttribute = /** @class */ (function (_super) {
97
97
  });
98
98
  });
99
99
  };
100
+ StyleVarAttribute.prototype.disconnect = function () {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0:
105
+ this.boundScope.offWithContext("change:" + this.key, this);
106
+ return [4 /*yield*/, _super.prototype.disconnect.call(this)];
107
+ case 1:
108
+ _a.sent();
109
+ return [2 /*return*/];
110
+ }
111
+ });
112
+ });
113
+ };
100
114
  StyleVarAttribute.prototype.update = function (e) {
101
115
  this.tag.element.style.setProperty("--" + this.styleVar, e.value);
102
116
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StyleVarAttribute.js","sourceRoot":"","sources":["../../src/attributes/StyleVarAttribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqC;AACrC,0CAAuC;AAMvC;IAAuC,qCAAS;IAAhD;;IA2BA,CAAC;IArBgB,mCAAO,GAApB;;;;;;wBACQ,QAAQ,GAAW,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBAEhD,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,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;wBAC3C,KAAA,IAAI,CAAA;wBAAc,qBAAM,GAAG,CAAC,QAAQ,EAAE,EAAA;;wBAAtC,GAAK,UAAU,GAAG,SAAoB,CAAC;wBACvC,IAAI,CAAC,UAAU,CAAC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I,CAAA;wBAAc,qBAAM,GAAG,CAAC,QAAQ,EAAE,EAAA;;wBAAtC,GAAK,UAAU,GAAG,SAAoB,CAAC;wBACvC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,YAAU,IAAI,CAAC,GAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;wBAE5D,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;IAEY,sCAAU,GAAvB;;;;;wBACI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,YAAU,IAAI,CAAC,GAAK,EAAE,IAAI,CAAC,CAAC;wBAC3D,qBAAM,iBAAM,UAAU,WAAE,EAAA;;wBAAxB,SAAwB,CAAC;;;;;KAC5B;IAED,kCAAM,GAAN,UAAO,CAAC;QACJ,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAK,IAAI,CAAC,QAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IA9BsB,0BAAQ,GAAY,KAAK,CAAC;IADxC,iBAAiB;QAD7B,mBAAQ,CAAC,SAAS,CAAC,eAAe,CAAC;OACvB,iBAAiB,CAgC7B;IAAD,wBAAC;CAAA,AAhCD,CAAuC,qBAAS,GAgC/C;AAhCY,8CAAiB"}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.1.136";
1
+ export declare const VERSION = "0.1.138";
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.1.136';
4
+ exports.VERSION = '0.1.138';
5
5
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vsn",
3
- "version": "0.1.136",
3
+ "version": "0.1.138",
4
4
  "description": "SEO Friendly Javascript/Typescript Framework",
5
5
  "keywords": [
6
6
  "framework",
package/src/Attribute.ts CHANGED
@@ -9,7 +9,8 @@ export enum AttributeState {
9
9
  Setup,
10
10
  Extracted,
11
11
  Connected,
12
- Built
12
+ Built,
13
+ Disconnected
13
14
  }
14
15
 
15
16
  export abstract class Attribute extends EventDispatcher {
@@ -64,6 +65,10 @@ export abstract class Attribute extends EventDispatcher {
64
65
  this.setState(AttributeState.Built);
65
66
  }
66
67
 
68
+ public async disconnect() {
69
+ this.setState(AttributeState.Disconnected);
70
+ }
71
+
67
72
  public async evaluate() {}
68
73
 
69
74
  public getAttributeValue(fallback: any = null) {
@@ -113,6 +118,7 @@ export abstract class Attribute extends EventDispatcher {
113
118
  }
114
119
 
115
120
  public deconstruct() {
121
+ this.disconnect();
116
122
  super.deconstruct();
117
123
  (this as any).tag = null;
118
124
  (this as any).slot = null;
package/src/Scope.ts CHANGED
@@ -33,8 +33,16 @@ export class Scope extends ScopeAbstract {
33
33
  if (this._data)
34
34
  this._data.deconstruct();
35
35
  this._data = null;
36
+
37
+ for (const child of this.children) {
38
+ child.deconstruct();
39
+ }
36
40
  this.children.length = 0;
37
- this._parentScope = null;
41
+
42
+ if (this._parentScope) {
43
+ this._parentScope.removeChild(this);
44
+ this._parentScope = null;
45
+ }
38
46
  }
39
47
 
40
48
  public get data(): ScopeData {
package/src/Tag.ts CHANGED
@@ -412,6 +412,7 @@ export class Tag extends DOMObject {
412
412
  }
413
413
 
414
414
  public setElementAttribute(key: string, value: any) {
415
+ if (!this.element) return null;
415
416
  if (this.isMagicAttribute(key)) {
416
417
  if (key === '@text')
417
418
  this.element.innerText = value;
@@ -441,6 +442,7 @@ export class Tag extends DOMObject {
441
442
  }
442
443
 
443
444
  public getElementAttribute(key: string): any {
445
+ if (!this.element) return null;
444
446
  if (this.isMagicAttribute(key)) {
445
447
  if (key === '@text')
446
448
  return this.element.innerText;
@@ -660,6 +662,8 @@ export class Tag extends DOMObject {
660
662
  handler.handler.call(handler.context, e);
661
663
  }
662
664
  }
665
+ this.scope.remove('$event');
666
+ this.scope.remove('$value');
663
667
  }
664
668
 
665
669
  public hasModifier(attribute: string, modifier: string): boolean {
@@ -55,6 +55,11 @@ export class Bind extends Attribute {
55
55
  await super.connect();
56
56
  }
57
57
 
58
+ public async disconnect() {
59
+ this.boundScope.offWithContext(`change:${this.key}`, this);
60
+ await super.disconnect();
61
+ }
62
+
58
63
  public async evaluate() {
59
64
  const elementValue = this.valueFromElement;
60
65
  if (!!elementValue)
@@ -22,6 +22,13 @@ export abstract class ScopeChange extends Attribute {
22
22
  await super.connect();
23
23
  }
24
24
 
25
+ public async disconnect() {
26
+ const binding = this.getAttributeBinding();
27
+ const ref: ScopeReference = this.tag.scope.getReference(binding, false);
28
+ (await ref.getScope()).offWithContext(`change:${await ref.getKey()}`, this);
29
+ await super.disconnect();
30
+ }
31
+
25
32
  async handleEvent(e) {
26
33
  await this.handler.evaluate(this.tag.scope, this.tag.dom, this.tag);
27
34
  }
@@ -16,10 +16,15 @@ export class StandardAttribute extends Attribute {
16
16
  }
17
17
 
18
18
  public async connect() {
19
- this.tag.scope.on(`change:${this.key}`, this.updateTo.bind(this));
19
+ this.tag.scope.on(`change:${this.key}`, this.updateTo, this);
20
20
  await super.connect();
21
21
  }
22
22
 
23
+ public async disconnect() {
24
+ this.tag.scope.offWithContext(`change:${this.key}`, this);
25
+ await super.disconnect();
26
+ }
27
+
23
28
  public mutate(mutation: MutationRecord) {
24
29
  super.mutate(mutation);
25
30
  this.updateFrom();
@@ -33,6 +33,11 @@ export class StyleAttribute extends Attribute {
33
33
  await super.connect();
34
34
  }
35
35
 
36
+ public async disconnect() {
37
+ this.styleScope.offWithContext(`change`, this);
38
+ await super.disconnect();
39
+ }
40
+
36
41
  public async extract() {
37
42
  this.updateFrom();
38
43
  this.updateTo();
@@ -29,6 +29,11 @@ export class StyleVarAttribute extends Attribute {
29
29
  await super.connect();
30
30
  }
31
31
 
32
+ public async disconnect() {
33
+ this.boundScope.offWithContext(`change:${this.key}`, this);
34
+ await super.disconnect();
35
+ }
36
+
32
37
  update(e) {
33
38
  this.tag.element.style.setProperty(`--${this.styleVar}`, e.value);
34
39
  }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.1.136';
1
+ export const VERSION = '0.1.138';
2
2