vsn 0.1.12 → 0.1.16
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 +15 -7
- package/demo/vision.js +1 -1
- package/dist/AST.d.ts +2 -2
- package/dist/AST.js +36 -19
- package/dist/AST.js.map +1 -1
- package/dist/Scope.d.ts +1 -0
- package/dist/Scope.js +27 -15
- package/dist/Scope.js.map +1 -1
- package/dist/Vision.d.ts +4 -1
- package/dist/Vision.js +9 -3
- package/dist/Vision.js.map +1 -1
- package/dist/attributes/_imports.d.ts +27 -27
- package/dist/attributes/_imports.js +55 -27
- package/dist/attributes/_imports.js.map +1 -1
- package/package.json +1 -1
- package/src/AST.ts +27 -17
- package/src/Scope.ts +11 -2
- package/src/Vision.ts +6 -3
- package/src/attributes/_imports.ts +27 -27
- package/test/DOM.spec.ts +2 -2
- package/test/Scope.spec.ts +14 -0
- package/test/attributes/Bind.spec.ts +13 -0
|
@@ -1,30 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
require("./
|
|
5
|
-
|
|
6
|
-
require("./
|
|
7
|
-
|
|
8
|
-
require("./
|
|
9
|
-
|
|
10
|
-
require("./
|
|
11
|
-
|
|
12
|
-
require("./
|
|
13
|
-
|
|
14
|
-
require("./
|
|
15
|
-
|
|
16
|
-
require("./
|
|
17
|
-
|
|
18
|
-
require("./
|
|
19
|
-
|
|
20
|
-
require("./
|
|
21
|
-
|
|
22
|
-
require("./
|
|
23
|
-
|
|
24
|
-
require("./
|
|
25
|
-
|
|
26
|
-
require("./
|
|
27
|
-
|
|
28
|
-
require("./
|
|
29
|
-
|
|
3
|
+
exports.TypeAttribute = exports.Template = exports.StandardAttribute = exports.SetAttribute = exports.ScopeChange = exports.ScopeAttribute = exports.RootAttribute = exports.Referenced = exports.Radio = exports.On = exports.Name = exports.ModelAttribute = exports.ListItemModel = exports.ListItem = exports.List = exports.KeyUp = exports.KeyDown = exports.JSONAttribute = exports.If = exports.Format = exports.Exec = exports.DisableIf = exports.ControllerAttribute = exports.ClickToggleClass = exports.ClickRemoveClass = exports.Bind = exports.AddClassIf = void 0;
|
|
4
|
+
var AddClassIf_1 = require("./AddClassIf");
|
|
5
|
+
Object.defineProperty(exports, "AddClassIf", { enumerable: true, get: function () { return AddClassIf_1.AddClassIf; } });
|
|
6
|
+
var Bind_1 = require("./Bind");
|
|
7
|
+
Object.defineProperty(exports, "Bind", { enumerable: true, get: function () { return Bind_1.Bind; } });
|
|
8
|
+
var ClickRemoveClass_1 = require("./ClickRemoveClass");
|
|
9
|
+
Object.defineProperty(exports, "ClickRemoveClass", { enumerable: true, get: function () { return ClickRemoveClass_1.ClickRemoveClass; } });
|
|
10
|
+
var ClickToggleClass_1 = require("./ClickToggleClass");
|
|
11
|
+
Object.defineProperty(exports, "ClickToggleClass", { enumerable: true, get: function () { return ClickToggleClass_1.ClickToggleClass; } });
|
|
12
|
+
var ControllerAttribute_1 = require("./ControllerAttribute");
|
|
13
|
+
Object.defineProperty(exports, "ControllerAttribute", { enumerable: true, get: function () { return ControllerAttribute_1.ControllerAttribute; } });
|
|
14
|
+
var DisableIf_1 = require("./DisableIf");
|
|
15
|
+
Object.defineProperty(exports, "DisableIf", { enumerable: true, get: function () { return DisableIf_1.DisableIf; } });
|
|
16
|
+
var Exec_1 = require("./Exec");
|
|
17
|
+
Object.defineProperty(exports, "Exec", { enumerable: true, get: function () { return Exec_1.Exec; } });
|
|
18
|
+
var Format_1 = require("./Format");
|
|
19
|
+
Object.defineProperty(exports, "Format", { enumerable: true, get: function () { return Format_1.Format; } });
|
|
20
|
+
var If_1 = require("./If");
|
|
21
|
+
Object.defineProperty(exports, "If", { enumerable: true, get: function () { return If_1.If; } });
|
|
22
|
+
var JSONAttribute_1 = require("./JSONAttribute");
|
|
23
|
+
Object.defineProperty(exports, "JSONAttribute", { enumerable: true, get: function () { return JSONAttribute_1.JSONAttribute; } });
|
|
24
|
+
var KeyDown_1 = require("./KeyDown");
|
|
25
|
+
Object.defineProperty(exports, "KeyDown", { enumerable: true, get: function () { return KeyDown_1.KeyDown; } });
|
|
26
|
+
var KeyUp_1 = require("./KeyUp");
|
|
27
|
+
Object.defineProperty(exports, "KeyUp", { enumerable: true, get: function () { return KeyUp_1.KeyUp; } });
|
|
28
|
+
var List_1 = require("./List");
|
|
29
|
+
Object.defineProperty(exports, "List", { enumerable: true, get: function () { return List_1.List; } });
|
|
30
|
+
var ListItem_1 = require("./ListItem");
|
|
31
|
+
Object.defineProperty(exports, "ListItem", { enumerable: true, get: function () { return ListItem_1.ListItem; } });
|
|
32
|
+
var ListItemModel_1 = require("./ListItemModel");
|
|
33
|
+
Object.defineProperty(exports, "ListItemModel", { enumerable: true, get: function () { return ListItemModel_1.ListItemModel; } });
|
|
34
|
+
var ModelAttribute_1 = require("./ModelAttribute");
|
|
35
|
+
Object.defineProperty(exports, "ModelAttribute", { enumerable: true, get: function () { return ModelAttribute_1.ModelAttribute; } });
|
|
36
|
+
var Name_1 = require("./Name");
|
|
37
|
+
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return Name_1.Name; } });
|
|
38
|
+
var On_1 = require("./On");
|
|
39
|
+
Object.defineProperty(exports, "On", { enumerable: true, get: function () { return On_1.On; } });
|
|
40
|
+
var Radio_1 = require("./Radio");
|
|
41
|
+
Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return Radio_1.Radio; } });
|
|
42
|
+
var Referenced_1 = require("./Referenced");
|
|
43
|
+
Object.defineProperty(exports, "Referenced", { enumerable: true, get: function () { return Referenced_1.Referenced; } });
|
|
44
|
+
var RootAttribute_1 = require("./RootAttribute");
|
|
45
|
+
Object.defineProperty(exports, "RootAttribute", { enumerable: true, get: function () { return RootAttribute_1.RootAttribute; } });
|
|
46
|
+
var ScopeAttribute_1 = require("./ScopeAttribute");
|
|
47
|
+
Object.defineProperty(exports, "ScopeAttribute", { enumerable: true, get: function () { return ScopeAttribute_1.ScopeAttribute; } });
|
|
48
|
+
var ScopeChange_1 = require("./ScopeChange");
|
|
49
|
+
Object.defineProperty(exports, "ScopeChange", { enumerable: true, get: function () { return ScopeChange_1.ScopeChange; } });
|
|
50
|
+
var SetAttribute_1 = require("./SetAttribute");
|
|
51
|
+
Object.defineProperty(exports, "SetAttribute", { enumerable: true, get: function () { return SetAttribute_1.SetAttribute; } });
|
|
52
|
+
var StandardAttribute_1 = require("./StandardAttribute");
|
|
53
|
+
Object.defineProperty(exports, "StandardAttribute", { enumerable: true, get: function () { return StandardAttribute_1.StandardAttribute; } });
|
|
54
|
+
var Template_1 = require("./Template");
|
|
55
|
+
Object.defineProperty(exports, "Template", { enumerable: true, get: function () { return Template_1.Template; } });
|
|
56
|
+
var TypeAttribute_1 = require("./TypeAttribute");
|
|
57
|
+
Object.defineProperty(exports, "TypeAttribute", { enumerable: true, get: function () { return TypeAttribute_1.TypeAttribute; } });
|
|
30
58
|
//# sourceMappingURL=_imports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_imports.js","sourceRoot":"","sources":["../../src/attributes/_imports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_imports.js","sourceRoot":"","sources":["../../src/attributes/_imports.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,+BAA4B;AAApB,4FAAA,IAAI,OAAA;AACZ,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,6DAA0D;AAAlD,0HAAA,mBAAmB,OAAA;AAC3B,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,+BAA4B;AAApB,4FAAA,IAAI,OAAA;AACZ,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,2BAAwB;AAAhB,wFAAA,EAAE,OAAA;AACV,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,qCAAkC;AAA1B,kGAAA,OAAO,OAAA;AACf,iCAA8B;AAAtB,8FAAA,KAAK,OAAA;AACb,+BAA4B;AAApB,4FAAA,IAAI,OAAA;AACZ,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,+BAA4B;AAApB,4FAAA,IAAI,OAAA;AACZ,2BAAwB;AAAhB,wFAAA,EAAE,OAAA;AACV,iCAA8B;AAAtB,8FAAA,KAAK,OAAA;AACb,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,uCAAoC;AAA5B,oGAAA,QAAQ,OAAA;AAChB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA"}
|
package/package.json
CHANGED
package/src/AST.ts
CHANGED
|
@@ -143,7 +143,7 @@ const TOKEN_PATTERNS: TokenPattern[] = [
|
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
type: TokenType.ELEMENT_ATTRIBUTE,
|
|
146
|
-
pattern:
|
|
146
|
+
pattern: /^\.?@[_a-zA-Z0-9]*/
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
type: TokenType.ELEMENT_REFERENCE,
|
|
@@ -151,7 +151,7 @@ const TOKEN_PATTERNS: TokenPattern[] = [
|
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
type: TokenType.ELEMENT_QUERY,
|
|
154
|
-
pattern:
|
|
154
|
+
pattern: /^\?\(([#.\[\]:,=\-_a-zA-Z0-9*\s]*[\]_a-zA-Z0-9*])\)/
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
157
|
type: TokenType.NAME,
|
|
@@ -868,7 +868,7 @@ class ArithmeticAssignmentNode extends Node implements TreeNode {
|
|
|
868
868
|
} else {
|
|
869
869
|
scopes.push(inner);
|
|
870
870
|
}
|
|
871
|
-
} else if (this.left instanceof ElementAttributeNode) {
|
|
871
|
+
} else if (this.left instanceof ElementAttributeNode && this.left.elementRef) {
|
|
872
872
|
scopes = await this.left.elementRef.evaluate(scope, dom, tag);
|
|
873
873
|
} else
|
|
874
874
|
scopes.push(scope);
|
|
@@ -1187,7 +1187,7 @@ class ElementAttributeNode extends Node implements TreeNode {
|
|
|
1187
1187
|
protected requiresPrep: boolean = true;
|
|
1188
1188
|
|
|
1189
1189
|
constructor(
|
|
1190
|
-
public readonly elementRef: ElementQueryNode,
|
|
1190
|
+
public readonly elementRef: ElementQueryNode | null,
|
|
1191
1191
|
public readonly attr: string
|
|
1192
1192
|
) {
|
|
1193
1193
|
super();
|
|
@@ -1198,9 +1198,10 @@ class ElementAttributeNode extends Node implements TreeNode {
|
|
|
1198
1198
|
}
|
|
1199
1199
|
|
|
1200
1200
|
protected _getChildNodes(): Node[] {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1201
|
+
let nodes = [];
|
|
1202
|
+
if (this.elementRef)
|
|
1203
|
+
nodes.push(this.elementRef)
|
|
1204
|
+
return nodes;
|
|
1204
1205
|
}
|
|
1205
1206
|
|
|
1206
1207
|
get attributeName(): string {
|
|
@@ -1210,17 +1211,30 @@ class ElementAttributeNode extends Node implements TreeNode {
|
|
|
1210
1211
|
}
|
|
1211
1212
|
|
|
1212
1213
|
async evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
1213
|
-
|
|
1214
|
+
let tags: TagList;
|
|
1215
|
+
if (this.elementRef) {
|
|
1216
|
+
tags = await this.elementRef.evaluate(scope, dom, tag);
|
|
1217
|
+
} else if (tag) {
|
|
1218
|
+
tags = new TagList(tag)
|
|
1219
|
+
} else {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1214
1223
|
if (tags.length === 1)
|
|
1215
1224
|
return tags[0].scope.get(`@${this.attributeName}`);
|
|
1225
|
+
|
|
1216
1226
|
return tags.map((tag) => tag.scope.get(`@${this.attributeName}`));
|
|
1217
1227
|
}
|
|
1218
1228
|
|
|
1219
1229
|
async prepare(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1230
|
+
if (this.elementRef) {
|
|
1231
|
+
await this.elementRef.prepare(scope, dom, tag);
|
|
1232
|
+
const tags: TagList = await this.elementRef.evaluate(scope, dom, tag);
|
|
1233
|
+
for (const t of tags)
|
|
1234
|
+
await t.watchAttribute(this.attributeName);
|
|
1235
|
+
} else if(tag) {
|
|
1223
1236
|
await tag.watchAttribute(this.attributeName);
|
|
1237
|
+
}
|
|
1224
1238
|
}
|
|
1225
1239
|
}
|
|
1226
1240
|
|
|
@@ -1273,7 +1287,7 @@ export class Tree {
|
|
|
1273
1287
|
let _scope: Scope = scope;
|
|
1274
1288
|
if (node instanceof ScopeMemberNode)
|
|
1275
1289
|
_scope = await node.scope.evaluate(scope, dom);
|
|
1276
|
-
else if (node instanceof ElementAttributeNode) {
|
|
1290
|
+
else if (node instanceof ElementAttributeNode && node.elementRef) {
|
|
1277
1291
|
_scope = (await node.elementRef.evaluate(scope, dom, tag))[0].scope;
|
|
1278
1292
|
}
|
|
1279
1293
|
|
|
@@ -1367,11 +1381,7 @@ export class Tree {
|
|
|
1367
1381
|
} else if (tokens[0].type === TokenType.L_BRACE) {
|
|
1368
1382
|
node = ObjectNode.parse(node, token, tokens);
|
|
1369
1383
|
} else if (tokens[0].type === TokenType.ELEMENT_ATTRIBUTE) {
|
|
1370
|
-
|
|
1371
|
-
node = new ElementAttributeNode(node, tokens[0].value);
|
|
1372
|
-
} else {
|
|
1373
|
-
node = new ScopeMemberNode(node, new LiteralNode<string>(tokens[0].value.substr(1)));
|
|
1374
|
-
}
|
|
1384
|
+
node = new ElementAttributeNode(node as any, tokens[0].value);
|
|
1375
1385
|
tokens.splice(0, 1);
|
|
1376
1386
|
} else if (node !== null && token.type === TokenType.PERIOD && tokens[1].type === TokenType.NAME) {
|
|
1377
1387
|
node = new ScopeMemberNode(
|
package/src/Scope.ts
CHANGED
|
@@ -110,6 +110,10 @@ export class WrappedArray<T> extends Array<T> {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
set length(num: number) {
|
|
113
|
+
this.setLength(num);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setLength(num: number) {
|
|
113
117
|
let c: number = 0;
|
|
114
118
|
const toRemove: T[] = [];
|
|
115
119
|
for (const item of this) {
|
|
@@ -363,8 +367,13 @@ export class Scope extends EventDispatcher {
|
|
|
363
367
|
continue;
|
|
364
368
|
}
|
|
365
369
|
|
|
366
|
-
if (this.wrapped[field] instanceof Array
|
|
367
|
-
this.wrapped[field]
|
|
370
|
+
if (this.wrapped[field] instanceof Array) {
|
|
371
|
+
if (!(this.wrapped[field] instanceof WrappedArray)) {
|
|
372
|
+
this.wrapped[field] = new WrappedArray(...toWrap[field]);
|
|
373
|
+
}
|
|
374
|
+
this.wrapped[field].bind('change', (...args) => {
|
|
375
|
+
this.trigger(`change:${field}`, ...args);
|
|
376
|
+
})
|
|
368
377
|
}
|
|
369
378
|
|
|
370
379
|
if (typeof this.wrapped[field] == 'object' && this.wrapped[field] && this.wrapped[field].constructor === Object) {
|
package/src/Vision.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {DOM} from "./DOM";
|
|
2
2
|
import {EventDispatcher} from "simple-ts-event-dispatcher";
|
|
3
|
-
import {
|
|
3
|
+
import {WrappedArray} from "./Scope";
|
|
4
4
|
import {DataModel} from "simple-ts-models";
|
|
5
5
|
import {Registry} from "./Registry";
|
|
6
6
|
import "./Types";
|
|
7
7
|
import "./Formats";
|
|
8
|
-
import "./attributes/_imports";
|
|
9
8
|
import {Configuration} from "./Configuration";
|
|
10
9
|
import {VisionHelper} from "./helpers/VisionHelper";
|
|
11
10
|
import {Tree} from "./AST";
|
|
@@ -57,7 +56,7 @@ export class Vision extends EventDispatcher {
|
|
|
57
56
|
await this._dom.buildFrom(document, true);
|
|
58
57
|
const now = (new Date()).getTime();
|
|
59
58
|
const setupTime = now - startTime;
|
|
60
|
-
console.warn(`Took ${setupTime}ms to start up VisionJS
|
|
59
|
+
console.warn(`Took ${setupTime}ms to start up VisionJS. https://www.vsnjs.com/`);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
public static get instance() {
|
|
@@ -68,6 +67,10 @@ export class Vision extends EventDispatcher {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
70
|
+
export * from "./attributes/_imports";
|
|
71
71
|
export * from './Registry';
|
|
72
72
|
export * from './Attribute';
|
|
73
|
+
export * from './AST';
|
|
74
|
+
export {DOM} from './DOM';
|
|
75
|
+
export {WrappedArray, Scope} from './Scope';
|
|
73
76
|
export const vision: Vision = Vision.instance;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
export {AddClassIf} from "./AddClassIf";
|
|
2
|
+
export {Bind} from "./Bind";
|
|
3
|
+
export {ClickRemoveClass} from "./ClickRemoveClass";
|
|
4
|
+
export {ClickToggleClass} from "./ClickToggleClass";
|
|
5
|
+
export {ControllerAttribute} from "./ControllerAttribute";
|
|
6
|
+
export {DisableIf} from "./DisableIf";
|
|
7
|
+
export {Exec} from "./Exec";
|
|
8
|
+
export {Format} from "./Format";
|
|
9
|
+
export {If} from "./If";
|
|
10
|
+
export {JSONAttribute} from "./JSONAttribute";
|
|
11
|
+
export {KeyDown} from "./KeyDown";
|
|
12
|
+
export {KeyUp} from "./KeyUp";
|
|
13
|
+
export {List} from "./List";
|
|
14
|
+
export {ListItem} from "./ListItem";
|
|
15
|
+
export {ListItemModel} from "./ListItemModel";
|
|
16
|
+
export {ModelAttribute} from "./ModelAttribute";
|
|
17
|
+
export {Name} from "./Name";
|
|
18
|
+
export {On} from "./On";
|
|
19
|
+
export {Radio} from "./Radio";
|
|
20
|
+
export {Referenced} from "./Referenced";
|
|
21
|
+
export {RootAttribute} from "./RootAttribute";
|
|
22
|
+
export {ScopeAttribute} from "./ScopeAttribute";
|
|
23
|
+
export {ScopeChange} from "./ScopeChange";
|
|
24
|
+
export {SetAttribute} from "./SetAttribute";
|
|
25
|
+
export {StandardAttribute} from "./StandardAttribute";
|
|
26
|
+
export {Template} from "./Template";
|
|
27
|
+
export {TypeAttribute} from "./TypeAttribute";
|
package/test/DOM.spec.ts
CHANGED
|
@@ -28,8 +28,8 @@ describe('DOM', () => {
|
|
|
28
28
|
`;
|
|
29
29
|
const dom = new DOM(document);
|
|
30
30
|
dom.once('built', async () => {
|
|
31
|
-
expect(await dom.eval('(
|
|
32
|
-
expect(await dom.eval('(
|
|
31
|
+
expect(await dom.eval('?(#parent).asd')).toBe(123);
|
|
32
|
+
expect(await dom.eval('?(#testing).asd')).toBe(345);
|
|
33
33
|
done();
|
|
34
34
|
});
|
|
35
35
|
});
|
package/test/Scope.spec.ts
CHANGED
|
@@ -40,4 +40,18 @@ describe('WrappedArray', () => {
|
|
|
40
40
|
expect(removes).toBe(2);
|
|
41
41
|
expect(a.length).toBe(1);
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
it("should trigger change events", async () => {
|
|
45
|
+
const a = new WrappedArray();
|
|
46
|
+
let changes: number = 0;
|
|
47
|
+
a.bind('change', (e) => {
|
|
48
|
+
changes += 1;
|
|
49
|
+
});
|
|
50
|
+
a.push(1);
|
|
51
|
+
a.push(2);
|
|
52
|
+
a.push(3);
|
|
53
|
+
a.setLength(0);
|
|
54
|
+
expect(changes).toBe(6);
|
|
55
|
+
expect(a.length).toBe(0);
|
|
56
|
+
});
|
|
43
57
|
});
|
|
@@ -18,6 +18,19 @@ describe('Bind', () => {
|
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
it("vsn-bind to work with inner text with @text", (done) => {
|
|
22
|
+
document.body.innerHTML = `
|
|
23
|
+
<span id="test" test="testing" vsn-bind="@test"></span>
|
|
24
|
+
`;
|
|
25
|
+
const dom = new DOM(document);
|
|
26
|
+
dom.once('built', async () => {
|
|
27
|
+
const tag = await dom.getTagForElement(document.getElementById('test'));
|
|
28
|
+
expect(tag).toBeTruthy();
|
|
29
|
+
expect(tag.scope.get('@test')).toBe('testing');
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
21
34
|
it("vsn-bind order of execution to be left to right and top to bottom", (done) => {
|
|
22
35
|
document.body.innerHTML = `
|
|
23
36
|
<span id="test" vsn-name="test" vsn-bind:id="test.id" vsn-bind="test.id">testing</span>
|