vsn 0.1.122 → 0.1.123
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 +1 -1
- package/demo/examples/replace-html.html +19 -0
- package/demo/resources/xhr-html.html +1 -0
- package/demo/{xhr.html → resources/xhr-lazy.html} +18 -1
- package/demo/vsn.js +2 -2
- package/demo/xhr-test.html +4 -0
- package/dist/AST/AssignmentNode.js +2 -3
- package/dist/AST/AssignmentNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.js +7 -9
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/NamedStackNode.js +6 -1
- package/dist/AST/NamedStackNode.js.map +1 -1
- package/dist/AST.d.ts +8 -0
- package/dist/AST.js +28 -2
- package/dist/AST.js.map +1 -1
- package/dist/DOM.js +2 -2
- package/dist/DOM.js.map +1 -1
- package/dist/Tag.js +3 -1
- package/dist/Tag.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/NamedStackNode.ts +4 -1
- package/src/AST.ts +25 -1
- package/src/DOM.ts +2 -2
- package/src/Tag.ts +3 -1
- package/src/version.ts +1 -1
package/src/AST.ts
CHANGED
|
@@ -415,7 +415,16 @@ export const AttributableNodes = [
|
|
|
415
415
|
ElementAttributeNode
|
|
416
416
|
];
|
|
417
417
|
|
|
418
|
+
export interface ExecutionContext {
|
|
419
|
+
scope: Scope;
|
|
420
|
+
dom: DOM;
|
|
421
|
+
tag: Tag;
|
|
422
|
+
tree: Tree;
|
|
423
|
+
|
|
424
|
+
}
|
|
425
|
+
|
|
418
426
|
export class Tree {
|
|
427
|
+
protected static executing: Set<ExecutionContext> = new Set<ExecutionContext>();
|
|
419
428
|
protected static cache: { [key: string]: Node } = {};
|
|
420
429
|
protected _root: Node;
|
|
421
430
|
|
|
@@ -438,7 +447,16 @@ export class Tree {
|
|
|
438
447
|
}
|
|
439
448
|
|
|
440
449
|
async evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
441
|
-
|
|
450
|
+
const context = {
|
|
451
|
+
scope: scope,
|
|
452
|
+
dom: dom,
|
|
453
|
+
tag: tag,
|
|
454
|
+
tree: this
|
|
455
|
+
};
|
|
456
|
+
Tree.executing.add(context);
|
|
457
|
+
const r = await this._root.evaluate(scope, dom, tag);
|
|
458
|
+
Tree.executing.delete(context);
|
|
459
|
+
return r;
|
|
442
460
|
}
|
|
443
461
|
|
|
444
462
|
async prepare(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
@@ -463,6 +481,12 @@ export class Tree {
|
|
|
463
481
|
}
|
|
464
482
|
}
|
|
465
483
|
|
|
484
|
+
public static reprepareExecutingTrees() {
|
|
485
|
+
Tree.executing.forEach(async context => {
|
|
486
|
+
await context.tree.prepare(context.scope, context.dom, context.tag);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
466
490
|
public static tokenize(code: string): Token[] {
|
|
467
491
|
const tokens: Token[] = [];
|
|
468
492
|
if (!code || code.length === 0)
|
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/Tag.ts
CHANGED
|
@@ -405,7 +405,9 @@ export class Tag extends DOMObject {
|
|
|
405
405
|
this.element.innerText = value;
|
|
406
406
|
else if (key === '@html') {
|
|
407
407
|
this.element.innerHTML = value;
|
|
408
|
-
DOM.instance.buildFrom(this.element)
|
|
408
|
+
DOM.instance.buildFrom(this.element).then((tag) => {
|
|
409
|
+
Tree.reprepareExecutingTrees();
|
|
410
|
+
});
|
|
409
411
|
} else if (key === '@value')
|
|
410
412
|
this.value = value;
|
|
411
413
|
else if (key === '@class' && value) {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.123';
|
|
2
2
|
|