vsn 0.1.122 → 0.1.124
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/demo.html +5 -2
- package/demo/examples/replace-html.html +19 -0
- package/demo/resources/xhr-animations.html +24 -0
- package/demo/resources/xhr-html.html +1 -0
- package/demo/{xhr.html → resources/xhr-lazy.html} +28 -2
- package/demo/silly-animations.html +12 -24
- package/demo/vsn.js +2 -2
- package/demo/xhr-test.html +4 -0
- package/dist/AST/ArrayNode.js +70 -18
- package/dist/AST/ArrayNode.js.map +1 -1
- package/dist/AST/AssignmentNode.js +93 -37
- package/dist/AST/AssignmentNode.js.map +1 -1
- package/dist/AST/BlockNode.js +17 -1
- package/dist/AST/BlockNode.js.map +1 -1
- package/dist/AST/ClassNode.js +225 -87
- package/dist/AST/ClassNode.js.map +1 -1
- package/dist/AST/ElementAttributeNode.js +55 -29
- package/dist/AST/ElementAttributeNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.js +55 -31
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/FunctionArgumentNode.js +57 -15
- package/dist/AST/FunctionArgumentNode.js.map +1 -1
- package/dist/AST/FunctionCallNode.js +120 -52
- package/dist/AST/FunctionCallNode.js.map +1 -1
- package/dist/AST/FunctionNode.js +57 -14
- package/dist/AST/FunctionNode.js.map +1 -1
- package/dist/AST/IfStatementNode.js +52 -12
- package/dist/AST/IfStatementNode.js.map +1 -1
- package/dist/AST/IndexNode.js +24 -3
- package/dist/AST/IndexNode.js.map +1 -1
- package/dist/AST/ModifierNode.js +1 -1
- package/dist/AST/ModifierNode.js.map +1 -1
- package/dist/AST/NamedStackNode.js +6 -1
- package/dist/AST/NamedStackNode.js.map +1 -1
- package/dist/AST/Node.d.ts +3 -2
- package/dist/AST/Node.js +132 -39
- package/dist/AST/Node.js.map +1 -1
- package/dist/AST/ObjectNode.js +17 -1
- package/dist/AST/ObjectNode.js.map +1 -1
- package/dist/AST/OnNode.js +23 -2
- package/dist/AST/OnNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.js +40 -16
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/AST/ScopeNodeAbstract.js +29 -8
- package/dist/AST/ScopeNodeAbstract.js.map +1 -1
- package/dist/AST/StringFormatNode.js +42 -5
- package/dist/AST/StringFormatNode.js.map +1 -1
- package/dist/AST/WASM/Function.js +20 -4
- package/dist/AST/WASM/Function.js.map +1 -1
- package/dist/AST/WASM.js +26 -10
- package/dist/AST/WASM.js.map +1 -1
- package/dist/AST/WithNode.js +81 -41
- package/dist/AST/WithNode.js.map +1 -1
- package/dist/AST.d.ts +8 -0
- package/dist/AST.js +119 -39
- package/dist/AST.js.map +1 -1
- package/dist/Attribute.d.ts +3 -0
- package/dist/Attribute.js +43 -19
- package/dist/Attribute.js.map +1 -1
- package/dist/Bencmark.js +77 -20
- package/dist/Bencmark.js.map +1 -1
- package/dist/Component.js +49 -15
- package/dist/Component.js.map +1 -1
- package/dist/DOM/DOMObject.d.ts +6 -1
- package/dist/DOM/DOMObject.js +22 -1
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/DOM.js +451 -194
- package/dist/DOM.js.map +1 -1
- package/dist/EventDispatcher.js +153 -39
- package/dist/EventDispatcher.js.map +1 -1
- package/dist/MessageList.js +37 -6
- package/dist/MessageList.js.map +1 -1
- package/dist/Model.js +27 -6
- package/dist/Model.js.map +1 -1
- package/dist/Modifiers.d.ts +17 -0
- package/dist/Modifiers.js +100 -0
- package/dist/Modifiers.js.map +1 -0
- package/dist/Scope/DynamicScopeData.js +38 -7
- package/dist/Scope/DynamicScopeData.js.map +1 -1
- package/dist/Scope/ScopeData.js +29 -8
- package/dist/Scope/ScopeData.js.map +1 -1
- package/dist/Scope/ScopeDataAbstract.js +103 -27
- package/dist/Scope/ScopeDataAbstract.js.map +1 -1
- package/dist/Scope/WrappedArray.js +112 -26
- package/dist/Scope/WrappedArray.js.map +1 -1
- package/dist/Scope/properties/ArrayProperty.js +17 -1
- package/dist/Scope/properties/ArrayProperty.js.map +1 -1
- package/dist/Scope/properties/Property.js +38 -7
- package/dist/Scope/properties/Property.js.map +1 -1
- package/dist/Scope.js +70 -13
- package/dist/Scope.js.map +1 -1
- package/dist/SimplePromise.js +71 -30
- package/dist/SimplePromise.js.map +1 -1
- package/dist/Tag/TagList.js +22 -1
- package/dist/Tag/TagList.js.map +1 -1
- package/dist/Tag.d.ts +5 -9
- package/dist/Tag.js +515 -196
- package/dist/Tag.js.map +1 -1
- package/dist/attributes/KeyAbstract.js +1 -1
- package/dist/attributes/KeyAbstract.js.map +1 -1
- package/dist/attributes/KeyDown.js +1 -1
- package/dist/attributes/KeyDown.js.map +1 -1
- package/dist/attributes/KeyUp.js +1 -1
- package/dist/attributes/KeyUp.js.map +1 -1
- package/dist/attributes/LazyAttribute.js +4 -2
- package/dist/attributes/LazyAttribute.js.map +1 -1
- package/dist/attributes/List.js +77 -30
- package/dist/attributes/List.js.map +1 -1
- package/dist/attributes/On.d.ts +1 -1
- package/dist/attributes/On.js +10 -10
- package/dist/attributes/On.js.map +1 -1
- package/dist/attributes/RootAttribute.js +29 -8
- package/dist/attributes/RootAttribute.js.map +1 -1
- package/dist/attributes/ScopeAttribute.js +30 -9
- package/dist/attributes/ScopeAttribute.js.map +1 -1
- package/dist/attributes/SetAttribute.js +32 -11
- package/dist/attributes/SetAttribute.js.map +1 -1
- package/dist/attributes/StyleAttribute.js +27 -6
- package/dist/attributes/StyleAttribute.js.map +1 -1
- package/dist/attributes/XHRAttribute.js +28 -7
- package/dist/attributes/XHRAttribute.js.map +1 -1
- package/dist/helpers/ElementHelper.js +25 -4
- package/dist/helpers/ElementHelper.js.map +1 -1
- package/dist/helpers/decorators.js +22 -1
- package/dist/helpers/decorators.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/AST/AssignmentNode.ts +2 -4
- package/src/AST/ElementStyleNode.ts +0 -1
- package/src/AST/FunctionNode.ts +2 -0
- package/src/AST/ModifierNode.ts +1 -1
- package/src/AST/NamedStackNode.ts +4 -1
- package/src/AST/Node.ts +10 -5
- package/src/AST/OnNode.ts +1 -1
- package/src/AST/ScopeNodeAbstract.ts +3 -3
- package/src/AST.ts +26 -2
- package/src/Attribute.ts +19 -8
- package/src/DOM/DOMObject.ts +4 -1
- package/src/DOM.ts +2 -2
- package/src/Modifiers.ts +54 -0
- package/src/Tag.ts +69 -38
- package/src/attributes/KeyAbstract.ts +1 -1
- package/src/attributes/KeyDown.ts +1 -1
- package/src/attributes/KeyUp.ts +1 -1
- package/src/attributes/LazyAttribute.ts +6 -2
- package/src/attributes/On.ts +10 -9
- package/src/attributes/XHRAttribute.ts +2 -2
- package/src/version.ts +1 -1
- package/tsconfig.base.json +2 -1
package/src/DOM.ts
CHANGED
|
@@ -313,7 +313,7 @@ export class DOM extends EventDispatcher {
|
|
|
313
313
|
const found: Element[] = [];
|
|
314
314
|
|
|
315
315
|
for (const element of elements) {
|
|
316
|
-
if (element[Tag.TaggedVariable]) {
|
|
316
|
+
if (element && element[Tag.TaggedVariable]) {
|
|
317
317
|
tags.push(element[Tag.TaggedVariable]);
|
|
318
318
|
found.push(element);
|
|
319
319
|
}
|
|
@@ -337,7 +337,7 @@ export class DOM extends EventDispatcher {
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
async getTagForElement(element: Element, create: boolean = false, forComponent: boolean = false) {
|
|
340
|
-
if (element[Tag.TaggedVariable])
|
|
340
|
+
if (element && element[Tag.TaggedVariable])
|
|
341
341
|
return element[Tag.TaggedVariable];
|
|
342
342
|
|
|
343
343
|
if (element && create) {
|
package/src/Modifiers.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
export class Modifier {
|
|
3
|
+
public readonly name: string;
|
|
4
|
+
public readonly arguments: string[];
|
|
5
|
+
|
|
6
|
+
constructor(modifier: string) {
|
|
7
|
+
const [name, ...args] = modifier.split(',');
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.arguments = args;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public getArguments(fallback: string[] = []): string[] {
|
|
13
|
+
return this.arguments.length ? this.arguments : fallback;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class Modifiers {
|
|
18
|
+
protected modifiers: Map<string, Modifier> = new Map<string, Modifier>();
|
|
19
|
+
|
|
20
|
+
constructor(modifiers: string[] = []) {
|
|
21
|
+
for (const modifier of modifiers) {
|
|
22
|
+
this.add(modifier);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public add(modifier: string) {
|
|
27
|
+
const m = new Modifier(modifier);
|
|
28
|
+
this.modifiers.set(m.name, m);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public has(name: string): boolean {
|
|
32
|
+
return this.modifiers.has(name);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public get(name: string): Modifier {
|
|
36
|
+
return this.modifiers.get(name);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get iter(): Modifier[] {
|
|
40
|
+
return Array.from(this.modifiers.values());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public get names(): string[] {
|
|
44
|
+
return this.iter.map(m => m.name);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get length(): number {
|
|
48
|
+
return this.modifiers.size;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public static fromAttribute(attribute: string): Modifiers {
|
|
52
|
+
return new Modifiers(attribute.split('|').splice(1));
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/Tag.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {Registry} from "./Registry";
|
|
|
9
9
|
import {DOMObject} from "./DOM/DOMObject";
|
|
10
10
|
import {Tree} from "./AST";
|
|
11
11
|
import {StyleAttribute} from "./attributes/StyleAttribute";
|
|
12
|
+
import {Modifiers} from "./Modifiers";
|
|
12
13
|
|
|
13
14
|
export enum TagState {
|
|
14
15
|
Instantiated,
|
|
@@ -27,8 +28,7 @@ export class Tag extends DOMObject {
|
|
|
27
28
|
public readonly deferredAttributes: Attribute[] = [];
|
|
28
29
|
protected _state: TagState;
|
|
29
30
|
protected _meta: { [key: string]: any; };
|
|
30
|
-
protected attributes: Attribute
|
|
31
|
-
protected attributeMap: { [key: string]: Attribute; };
|
|
31
|
+
protected attributes: Map<string, Attribute> = new Map<string, Attribute>();
|
|
32
32
|
protected _nonDeferredAttributes: Attribute[] = [];
|
|
33
33
|
protected _parentTag: Tag;
|
|
34
34
|
protected _children: Tag[] = [];
|
|
@@ -78,8 +78,6 @@ export class Tag extends DOMObject {
|
|
|
78
78
|
element[Tag.TaggedVariable] = this;
|
|
79
79
|
this.rawAttributes = {};
|
|
80
80
|
this.parsedAttributes = {};
|
|
81
|
-
this.attributes = [];
|
|
82
|
-
this.attributeMap = {};
|
|
83
81
|
this.onEventHandlers = {};
|
|
84
82
|
this.analyzeElementAttributes();
|
|
85
83
|
this._state = TagState.Instantiated;
|
|
@@ -97,14 +95,23 @@ export class Tag extends DOMObject {
|
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
public getAttributesWithState(state: AttributeState): Attribute[] {
|
|
100
|
-
|
|
98
|
+
const attrs: Attribute[] = [];
|
|
99
|
+
for (const attr of this.attributes.values()) {
|
|
100
|
+
if (attr.state === state)
|
|
101
|
+
attrs.push(attr);
|
|
102
|
+
}
|
|
103
|
+
return attrs;
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
public get nonDeferredAttributes(): Attribute[] {
|
|
104
107
|
if (this._nonDeferredAttributes.length > 0)
|
|
105
108
|
return this._nonDeferredAttributes;
|
|
106
109
|
|
|
107
|
-
const attrs: Attribute[] =
|
|
110
|
+
const attrs: Attribute[] = [];
|
|
111
|
+
for (const attr of this.attributes.values()) {
|
|
112
|
+
if (attr.state !== AttributeState.Deferred)
|
|
113
|
+
attrs.push(attr);
|
|
114
|
+
}
|
|
108
115
|
this._nonDeferredAttributes = attrs;
|
|
109
116
|
return attrs;
|
|
110
117
|
}
|
|
@@ -146,7 +153,7 @@ export class Tag extends DOMObject {
|
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
mutate(mutation: MutationRecord): void {
|
|
149
|
-
this.attributes.
|
|
156
|
+
this.attributes.forEach(attr => attr.mutate(mutation));
|
|
150
157
|
this.dispatch('mutate', mutation);
|
|
151
158
|
}
|
|
152
159
|
|
|
@@ -185,10 +192,6 @@ export class Tag extends DOMObject {
|
|
|
185
192
|
return null;
|
|
186
193
|
}
|
|
187
194
|
|
|
188
|
-
getAttributeModifiers(attr: string): string[] {
|
|
189
|
-
return attr.split('|').splice(1);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
195
|
get isInput(): boolean {
|
|
193
196
|
return this.inputTags.indexOf(this.element.tagName.toLowerCase()) > -1;
|
|
194
197
|
}
|
|
@@ -390,7 +393,7 @@ export class Tag extends DOMObject {
|
|
|
390
393
|
public async getAttribute<T = Attribute>(key: string): Promise<T> {
|
|
391
394
|
const cls: any = await Registry.instance.attributes.get(key);
|
|
392
395
|
if (!cls) return;
|
|
393
|
-
for (const attr of this.attributes)
|
|
396
|
+
for (const attr of this.attributes.values())
|
|
394
397
|
if (attr instanceof cls)
|
|
395
398
|
return attr as any as T;
|
|
396
399
|
}
|
|
@@ -405,7 +408,9 @@ export class Tag extends DOMObject {
|
|
|
405
408
|
this.element.innerText = value;
|
|
406
409
|
else if (key === '@html') {
|
|
407
410
|
this.element.innerHTML = value;
|
|
408
|
-
DOM.instance.buildFrom(this.element)
|
|
411
|
+
DOM.instance.buildFrom(this.element).then((tag) => {
|
|
412
|
+
Tree.reprepareExecutingTrees();
|
|
413
|
+
});
|
|
409
414
|
} else if (key === '@value')
|
|
410
415
|
this.value = value;
|
|
411
416
|
else if (key === '@class' && value) {
|
|
@@ -479,8 +484,7 @@ export class Tag extends DOMObject {
|
|
|
479
484
|
const slot: Tag = this.isSlot ? this : null;
|
|
480
485
|
for (const tag of tags) {
|
|
481
486
|
for (let attr in this.rawAttributes) {
|
|
482
|
-
if (tag.
|
|
483
|
-
continue;
|
|
487
|
+
if (tag.attributes.has(attr)) continue;
|
|
484
488
|
|
|
485
489
|
if (this.hasModifier(attr, 'mobile') && !isMobile)
|
|
486
490
|
continue;
|
|
@@ -496,8 +500,7 @@ export class Tag extends DOMObject {
|
|
|
496
500
|
|
|
497
501
|
const attrObj = attrClass.create(tag, attr, attrClass, slot);
|
|
498
502
|
|
|
499
|
-
tag.attributes.
|
|
500
|
-
tag.attributeMap[attr] = attrObj;
|
|
503
|
+
tag.attributes.set(attr, attrObj);
|
|
501
504
|
if (defer && attrClass.canDefer) {
|
|
502
505
|
await attrObj.defer();
|
|
503
506
|
tag.deferredAttributes.push(attrObj);
|
|
@@ -555,7 +558,7 @@ export class Tag extends DOMObject {
|
|
|
555
558
|
const tags: Tag[] = await this.getTagsToBuild() as Tag[];
|
|
556
559
|
for (const tag of tags) {
|
|
557
560
|
if (tag.isInput) {
|
|
558
|
-
tag.addEventHandler('input',
|
|
561
|
+
tag.addEventHandler('input', null, tag.inputMutation, tag);
|
|
559
562
|
}
|
|
560
563
|
|
|
561
564
|
for (const attr of tag.getAttributesWithState(AttributeState.Extracted)) {
|
|
@@ -610,12 +613,42 @@ export class Tag extends DOMObject {
|
|
|
610
613
|
|
|
611
614
|
this.scope.set('$event', e);
|
|
612
615
|
this.scope.set('$value', this.value);
|
|
616
|
+
let preventedDefault = false;
|
|
613
617
|
for (const handler of this.onEventHandlers[eventType]) {
|
|
614
|
-
handler.
|
|
618
|
+
if (!preventedDefault && handler.modifiers.has('preventdefault') && e.cancelable) {
|
|
619
|
+
e.preventDefault();
|
|
620
|
+
preventedDefault = true;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (handler.modifiers.has('once'))
|
|
624
|
+
this.removeEventHandler(handler.event, handler.handler, handler.context);
|
|
625
|
+
|
|
626
|
+
if (handler.modifiers.has('throttle')) {
|
|
627
|
+
const modifierArguments = handler.modifiers.get('throttle').getArguments(['1000']);
|
|
628
|
+
const throttleTime = parseInt(modifierArguments[0]);
|
|
629
|
+
const now = Math.floor(Date.now());
|
|
630
|
+
if (!handler.state.lastCalled || handler.state.lastCalled + throttleTime < now) {
|
|
631
|
+
handler.state.lastCalled = now;
|
|
632
|
+
} else {
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
if (handler.modifiers.has('debounce')) {
|
|
638
|
+
clearTimeout(handler.state.debounceTimeout);
|
|
639
|
+
const modifierArguments = handler.modifiers.get('debounce').getArguments(['1000']);
|
|
640
|
+
const debounceTime = parseInt(modifierArguments[0]);
|
|
641
|
+
handler.state.debounceTimeout = setTimeout(async () => {
|
|
642
|
+
await handler.handler.call(handler.context, e);
|
|
643
|
+
}, debounceTime);
|
|
644
|
+
} else {
|
|
645
|
+
handler.handler.call(handler.context, e);
|
|
646
|
+
}
|
|
615
647
|
}
|
|
616
648
|
}
|
|
617
649
|
|
|
618
650
|
public hasModifier(attribute: string, modifier: string): boolean {
|
|
651
|
+
this.attributes
|
|
619
652
|
return attribute.indexOf(`|${modifier}`) > -1;
|
|
620
653
|
}
|
|
621
654
|
|
|
@@ -623,28 +656,32 @@ export class Tag extends DOMObject {
|
|
|
623
656
|
return attribute.replace(`|${modifier}`, '');
|
|
624
657
|
}
|
|
625
658
|
|
|
626
|
-
public addEventHandler(eventType: string, modifiers:
|
|
659
|
+
public addEventHandler(eventType: string, modifiers: Modifiers, handler, context: any = null) {
|
|
627
660
|
let passiveValue: boolean = null;
|
|
628
|
-
|
|
661
|
+
modifiers = modifiers || new Modifiers();
|
|
662
|
+
|
|
663
|
+
if (modifiers.has('active')) {
|
|
629
664
|
passiveValue = false;
|
|
630
|
-
} else if (modifiers.
|
|
665
|
+
} else if (modifiers.has('passive')) {
|
|
631
666
|
passiveValue = true;
|
|
632
667
|
}
|
|
633
668
|
|
|
634
669
|
if (!this.onEventHandlers[eventType]) {
|
|
635
670
|
this.onEventHandlers[eventType] = [];
|
|
636
671
|
const element: HTMLElement | Window = On.WindowEvents.indexOf(eventType) > -1 && window ? window : this.element;
|
|
637
|
-
const
|
|
672
|
+
const eventListenerOpts: any = {};
|
|
638
673
|
if (eventType.indexOf('touch') > -1 || passiveValue !== null)
|
|
639
|
-
|
|
674
|
+
eventListenerOpts['passive'] = passiveValue === null && true || passiveValue;
|
|
640
675
|
|
|
641
|
-
element.addEventListener(eventType, this.handleEvent.bind(this, eventType),
|
|
676
|
+
element.addEventListener(eventType, this.handleEvent.bind(this, eventType), eventListenerOpts);
|
|
642
677
|
}
|
|
643
678
|
|
|
644
679
|
this.onEventHandlers[eventType].push({
|
|
645
680
|
handler: handler,
|
|
646
681
|
event: eventType,
|
|
647
682
|
context: context,
|
|
683
|
+
modifiers: modifiers,
|
|
684
|
+
state: {}
|
|
648
685
|
});
|
|
649
686
|
}
|
|
650
687
|
|
|
@@ -687,32 +724,26 @@ export class Tag extends DOMObject {
|
|
|
687
724
|
}
|
|
688
725
|
|
|
689
726
|
async watchAttribute(attributeName: string) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
return attribute;
|
|
693
|
-
}
|
|
727
|
+
if (this.attributes.has(attributeName) && this.attributes.get(attributeName) instanceof StandardAttribute) {
|
|
728
|
+
return this.attributes.get(attributeName);
|
|
694
729
|
}
|
|
695
730
|
|
|
696
731
|
this.createScope(true);
|
|
697
|
-
|
|
698
732
|
const standardAttribute = new StandardAttribute(this, attributeName);
|
|
699
|
-
this.attributes.
|
|
733
|
+
this.attributes.set(attributeName, standardAttribute);
|
|
700
734
|
await this.setupAttribute(standardAttribute);
|
|
701
735
|
|
|
702
736
|
return standardAttribute;
|
|
703
737
|
}
|
|
704
738
|
|
|
705
739
|
async watchStyle(styleName: string) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return attribute;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
740
|
+
if (this.attributes.has('style'))
|
|
741
|
+
return this.attributes.get('style');
|
|
711
742
|
|
|
712
743
|
this.createScope(true);
|
|
713
744
|
|
|
714
745
|
const styleAttribute = new StyleAttribute(this, 'style');
|
|
715
|
-
this.attributes.
|
|
746
|
+
this.attributes.set('style', styleAttribute);
|
|
716
747
|
await this.setupAttribute(styleAttribute);
|
|
717
748
|
|
|
718
749
|
return styleAttribute;
|
|
@@ -733,7 +764,7 @@ export class Tag extends DOMObject {
|
|
|
733
764
|
|
|
734
765
|
deconstruct() {
|
|
735
766
|
this.attributes.forEach(attr => attr.deconstruct());
|
|
736
|
-
this.attributes.
|
|
767
|
+
this.attributes.clear();
|
|
737
768
|
this._children.forEach(child => child.deconstruct());
|
|
738
769
|
this._children.length = 0;
|
|
739
770
|
super.deconstruct();
|
|
@@ -9,7 +9,7 @@ export abstract class KeyAbstract extends On {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public async connect() {
|
|
12
|
-
this.tag.addEventHandler('keydown', this.
|
|
12
|
+
this.tag.addEventHandler('keydown', this.modifiers, this.handleEvent, this);
|
|
13
13
|
await super.connect();
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -4,7 +4,7 @@ import {Registry} from "../Registry";
|
|
|
4
4
|
@Registry.attribute('vsn-key-down')
|
|
5
5
|
export class KeyDown extends KeyAbstract {
|
|
6
6
|
public async connect() {
|
|
7
|
-
this.tag.addEventHandler('keydown', this.
|
|
7
|
+
this.tag.addEventHandler('keydown', this.modifiers, this.handleEvent, this);
|
|
8
8
|
await super.connect();
|
|
9
9
|
}
|
|
10
10
|
}
|
package/src/attributes/KeyUp.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {Registry} from "../Registry";
|
|
|
4
4
|
@Registry.attribute('vsn-key-up')
|
|
5
5
|
export class KeyUp extends KeyAbstract {
|
|
6
6
|
public async connect() {
|
|
7
|
-
this.tag.addEventHandler('keyup', this.
|
|
7
|
+
this.tag.addEventHandler('keyup', this.modifiers, this.handleEvent, this);
|
|
8
8
|
await super.connect();
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Registry} from "../Registry";
|
|
2
2
|
import {On} from "./On";
|
|
3
|
+
import {Modifiers} from "../Modifiers";
|
|
3
4
|
|
|
4
5
|
@Registry.attribute('vsn-lazy')
|
|
5
6
|
export class LazyAttribute extends On {
|
|
@@ -12,14 +13,17 @@ export class LazyAttribute extends On {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
public async connect() {
|
|
15
|
-
this.
|
|
16
|
+
if (!this.modifiers.has('active'))
|
|
17
|
+
this.modifiers.add('passive');
|
|
18
|
+
|
|
19
|
+
this.tag.addEventHandler('scroll', this.modifiers, this.handleEvent, this);
|
|
16
20
|
await this.handleEvent();
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
async handleEvent(e?: Event) {
|
|
20
24
|
if (!this.loaded && window.scrollY + window.outerHeight >= this.eleTop) {
|
|
21
25
|
this.loaded = true;
|
|
22
|
-
await
|
|
26
|
+
await super.handleEvent(e);
|
|
23
27
|
this.tag.removeEventHandler('scroll', this.handleEvent, this);
|
|
24
28
|
}
|
|
25
29
|
}
|
package/src/attributes/On.ts
CHANGED
|
@@ -18,21 +18,22 @@ export abstract class On extends Attribute {
|
|
|
18
18
|
'unload',
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
protected async getTree(): Promise<Tree> {
|
|
22
|
+
if (!this.handler) {
|
|
23
|
+
const code: string = this.getAttributeValue();
|
|
24
|
+
this.handler = new Tree(code);
|
|
25
|
+
await this.handler.prepare(this.tag.scope, this.tag.dom, this.tag);
|
|
26
|
+
}
|
|
27
|
+
return this.handler;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
async handleEvent(e) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await this.handler.evaluate(this.tag.scope, this.tag.dom, this.tag);
|
|
31
|
+
const tree = await this.getTree();
|
|
32
|
+
await tree.evaluate(this.tag.scope, this.tag.dom, this.tag);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
public async connect() {
|
|
35
|
-
this.tag.addEventHandler(this.getAttributeBinding(), this.
|
|
36
|
+
this.tag.addEventHandler(this.getAttributeBinding(), this.modifiers, this.handleEvent, this);
|
|
36
37
|
await super.connect();
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -22,9 +22,9 @@ export class XHRAttribute extends Attribute {
|
|
|
22
22
|
|
|
23
23
|
public async connect() {
|
|
24
24
|
if (this.isForm) {
|
|
25
|
-
this.tag.addEventHandler('submit', this.
|
|
25
|
+
this.tag.addEventHandler('submit', this.modifiers, this.handleEvent, this);
|
|
26
26
|
} else if (this.isAnchor) {
|
|
27
|
-
this.tag.addEventHandler('click', this.
|
|
27
|
+
this.tag.addEventHandler('click', this.modifiers, this.handleEvent, this);
|
|
28
28
|
}
|
|
29
29
|
await super.connect();
|
|
30
30
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.124';
|
|
2
2
|
|