vsn 0.1.45 → 0.1.48

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.
@@ -2,15 +2,9 @@ import {Attribute} from "../Attribute";
2
2
 
3
3
  export class StandardAttribute extends Attribute {
4
4
  public static readonly canDefer: boolean = false;
5
- protected static readonly magicAttributes: string[] = [
6
- '@text',
7
- '@html',
8
- '@class',
9
- '@value'
10
- ];
11
5
 
12
6
  public async setup() {
13
- if (StandardAttribute.magicAttributes.indexOf(this.key) === -1 && !this.tag.element.hasAttribute(this.attributeName)) {
7
+ if (!this.tag.isMagicAttribute(this.key) && !this.tag.element.hasAttribute(this.attributeName)) {
14
8
  this.tag.element.setAttribute(this.attributeName, '');
15
9
  }
16
10
  await super.setup();
@@ -51,7 +45,7 @@ export class StandardAttribute extends Attribute {
51
45
 
52
46
  public updateTo() {
53
47
  if (this.needsToBeSynced)
54
- this.value = this.tag.scope.get(`@${this.attributeName}`);
48
+ this.value = this.tag.scope.get(this.key);
55
49
  }
56
50
 
57
51
  public updateFrom() {
@@ -64,32 +58,10 @@ export class StandardAttribute extends Attribute {
64
58
  }
65
59
 
66
60
  public set value(value: any) {
67
- if (this.key === '@text')
68
- this.tag.element.innerText = value;
69
- else if (this.key === '@html')
70
- this.tag.element.innerHTML = value;
71
- else if (this.key === '@value')
72
- this.tag.value = value;
73
- else if (this.key === '@class' && value) {
74
- this.tag.element.classList.remove(...Array.from(this.tag.element.classList));
75
- const classes: string[] = value instanceof Array ? value : [value];
76
- if (classes.length)
77
- this.tag.element.classList.add(...classes);
78
- }
79
- else
80
- this.tag.element.setAttribute(this.attributeName, value);
61
+ this.tag.setElementAttribute(this.tag.isMagicAttribute(this.key) ? this.key : this.attributeName, value);
81
62
  }
82
63
 
83
64
  public get value(): any {
84
- if (this.key === '@text')
85
- return this.tag.element.innerText;
86
- else if (this.key === '@html')
87
- return this.tag.element.innerHTML;
88
- else if (this.key === '@value')
89
- return this.tag.value;
90
- else if (this.key === '@class') {
91
- return Array.from(this.tag.element.classList);
92
- } else
93
- return this.tag.element.getAttribute(this.attributeName);
65
+ return this.tag.getElementAttribute(this.tag.isMagicAttribute(this.key) ? this.key : this.attributeName);
94
66
  }
95
67
  }
@@ -0,0 +1,5 @@
1
+
2
+ declare module "*.vsn" {
3
+ const content: string;
4
+ export default content;
5
+ }