vsn 0.1.127 → 0.1.128
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/examples/item-filtering.html +45 -0
- package/demo/vsn.js +2 -2
- package/dist/AST/ElementAttributeNode.d.ts +3 -1
- package/dist/AST/ElementAttributeNode.js +41 -8
- package/dist/AST/ElementAttributeNode.js.map +1 -1
- package/dist/AST/ElementStyleNode.d.ts +3 -1
- package/dist/AST/ElementStyleNode.js +22 -3
- package/dist/AST/ElementStyleNode.js.map +1 -1
- package/dist/AST/ScopeMemberNode.js +2 -1
- package/dist/AST/ScopeMemberNode.js.map +1 -1
- package/dist/DOM/DOMObject.d.ts +2 -2
- package/dist/DOM/DOMObject.js +46 -0
- package/dist/DOM/DOMObject.js.map +1 -1
- package/dist/EventDispatcher.d.ts +1 -0
- package/dist/EventDispatcher.js +62 -22
- package/dist/EventDispatcher.js.map +1 -1
- package/dist/Tag.js +4 -0
- package/dist/Tag.js.map +1 -1
- package/dist/attributes/StyleVarAttribute.d.ts +10 -0
- package/dist/attributes/StyleVarAttribute.js +110 -0
- package/dist/attributes/StyleVarAttribute.js.map +1 -0
- package/dist/attributes/_imports.d.ts +1 -0
- package/dist/attributes/_imports.js +3 -1
- package/dist/attributes/_imports.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/src/AST/ElementAttributeNode.ts +24 -3
- package/src/AST/ElementStyleNode.ts +14 -3
- package/src/DOM/DOMObject.ts +2 -2
- package/src/EventDispatcher.ts +30 -5
- package/src/Tag.ts +5 -1
- package/src/attributes/StyleVarAttribute.ts +35 -0
- package/src/attributes/_imports.ts +1 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Attribute } from "../Attribute";
|
|
2
|
+
import { Scope } from "../Scope";
|
|
3
|
+
export declare class StyleVarAttribute extends Attribute {
|
|
4
|
+
static readonly canDefer: boolean;
|
|
5
|
+
protected key?: string;
|
|
6
|
+
protected styleVar?: string;
|
|
7
|
+
protected boundScope?: Scope;
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
update(e: any): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (_) try {
|
|
39
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.StyleVarAttribute = void 0;
|
|
61
|
+
var Registry_1 = require("../Registry");
|
|
62
|
+
var Attribute_1 = require("../Attribute");
|
|
63
|
+
var StyleVarAttribute = /** @class */ (function (_super) {
|
|
64
|
+
__extends(StyleVarAttribute, _super);
|
|
65
|
+
function StyleVarAttribute() {
|
|
66
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
67
|
+
}
|
|
68
|
+
StyleVarAttribute.prototype.connect = function () {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var scopeKey, ref, _a, _b;
|
|
71
|
+
return __generator(this, function (_c) {
|
|
72
|
+
switch (_c.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
scopeKey = this.getAttributeValue();
|
|
75
|
+
try {
|
|
76
|
+
ref = this.tag.scope.getReference(scopeKey);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
console.error('error', e);
|
|
80
|
+
return [2 /*return*/];
|
|
81
|
+
}
|
|
82
|
+
_a = this;
|
|
83
|
+
return [4 /*yield*/, ref.getKey()];
|
|
84
|
+
case 1:
|
|
85
|
+
_a.key = _c.sent();
|
|
86
|
+
this.styleVar = this.getAttributeBinding();
|
|
87
|
+
_b = this;
|
|
88
|
+
return [4 /*yield*/, ref.getScope()];
|
|
89
|
+
case 2:
|
|
90
|
+
_b.boundScope = _c.sent();
|
|
91
|
+
this.boundScope.on("change:" + this.key, this.update, this);
|
|
92
|
+
return [4 /*yield*/, _super.prototype.connect.call(this)];
|
|
93
|
+
case 3:
|
|
94
|
+
_c.sent();
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
StyleVarAttribute.prototype.update = function (e) {
|
|
101
|
+
this.tag.element.style.setProperty("--" + this.styleVar, e.value);
|
|
102
|
+
};
|
|
103
|
+
StyleVarAttribute.canDefer = false;
|
|
104
|
+
StyleVarAttribute = __decorate([
|
|
105
|
+
Registry_1.Registry.attribute('vsn-style-var')
|
|
106
|
+
], StyleVarAttribute);
|
|
107
|
+
return StyleVarAttribute;
|
|
108
|
+
}(Attribute_1.Attribute));
|
|
109
|
+
exports.StyleVarAttribute = StyleVarAttribute;
|
|
110
|
+
//# sourceMappingURL=StyleVarAttribute.js.map
|
|
@@ -0,0 +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,EAAE,CAAC,YAAU,IAAI,CAAC,GAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;wBAE5D,qBAAM,iBAAM,OAAO,WAAE,EAAA;;wBAArB,SAAqB,CAAC;;;;;KACzB;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;IAzBsB,0BAAQ,GAAY,KAAK,CAAC;IADxC,iBAAiB;QAD7B,mBAAQ,CAAC,SAAS,CAAC,eAAe,CAAC;OACvB,iBAAiB,CA2B7B;IAAD,wBAAC;CAAA,AA3BD,CAAuC,qBAAS,GA2B/C;AA3BY,8CAAiB"}
|
|
@@ -25,6 +25,7 @@ export { ServiceAttribute } from "./ServiceAttribute";
|
|
|
25
25
|
export { SetAttribute } from "./SetAttribute";
|
|
26
26
|
export { StandardAttribute } from "./StandardAttribute";
|
|
27
27
|
export { StyleAttribute } from "./StyleAttribute";
|
|
28
|
+
export { StyleVarAttribute } from "./StyleVarAttribute";
|
|
28
29
|
export { TemplateAttribute } from "./TemplateAttribute";
|
|
29
30
|
export { TypeAttribute } from "./TypeAttribute";
|
|
30
31
|
export { XHRAttribute } from "./XHRAttribute";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XHRAttribute = exports.TypeAttribute = exports.TemplateAttribute = exports.StyleAttribute = exports.StandardAttribute = exports.SetAttribute = exports.ServiceAttribute = exports.ScriptAttribute = exports.ScopeChange = exports.ScopeAttribute = exports.RootAttribute = exports.Referenced = exports.On = exports.Name = exports.ModelAttribute = exports.ListItemModel = exports.ListItem = exports.List = exports.LazyAttribute = exports.KeyUp = exports.KeyDown = exports.JSONAttribute = exports.If = exports.Format = exports.Exec = exports.DisableIf = exports.ControllerAttribute = exports.ComponentAttribute = exports.Bind = exports.AddClassIf = void 0;
|
|
3
|
+
exports.XHRAttribute = exports.TypeAttribute = exports.TemplateAttribute = exports.StyleVarAttribute = exports.StyleAttribute = exports.StandardAttribute = exports.SetAttribute = exports.ServiceAttribute = exports.ScriptAttribute = exports.ScopeChange = exports.ScopeAttribute = exports.RootAttribute = exports.Referenced = exports.On = exports.Name = exports.ModelAttribute = exports.ListItemModel = exports.ListItem = exports.List = exports.LazyAttribute = exports.KeyUp = exports.KeyDown = exports.JSONAttribute = exports.If = exports.Format = exports.Exec = exports.DisableIf = exports.ControllerAttribute = exports.ComponentAttribute = exports.Bind = exports.AddClassIf = void 0;
|
|
4
4
|
var AddClassIf_1 = require("./AddClassIf");
|
|
5
5
|
Object.defineProperty(exports, "AddClassIf", { enumerable: true, get: function () { return AddClassIf_1.AddClassIf; } });
|
|
6
6
|
var Bind_1 = require("./Bind");
|
|
@@ -55,6 +55,8 @@ var StandardAttribute_1 = require("./StandardAttribute");
|
|
|
55
55
|
Object.defineProperty(exports, "StandardAttribute", { enumerable: true, get: function () { return StandardAttribute_1.StandardAttribute; } });
|
|
56
56
|
var StyleAttribute_1 = require("./StyleAttribute");
|
|
57
57
|
Object.defineProperty(exports, "StyleAttribute", { enumerable: true, get: function () { return StyleAttribute_1.StyleAttribute; } });
|
|
58
|
+
var StyleVarAttribute_1 = require("./StyleVarAttribute");
|
|
59
|
+
Object.defineProperty(exports, "StyleVarAttribute", { enumerable: true, get: function () { return StyleVarAttribute_1.StyleVarAttribute; } });
|
|
58
60
|
var TemplateAttribute_1 = require("./TemplateAttribute");
|
|
59
61
|
Object.defineProperty(exports, "TemplateAttribute", { enumerable: true, get: function () { return TemplateAttribute_1.TemplateAttribute; } });
|
|
60
62
|
var TypeAttribute_1 = require("./TypeAttribute");
|
|
@@ -1 +1 @@
|
|
|
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,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,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,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,+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,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,+CAA4C;AAApC,4GAAA,YAAY,OAAA"}
|
|
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,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,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,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,+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,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AACtB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,yDAAsD;AAA9C,sHAAA,iBAAiB,OAAA;AACzB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,+CAA4C;AAApC,4GAAA,YAAY,OAAA"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.128";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vsn",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.128",
|
|
4
4
|
"description": "SEO Friendly Javascript/Typescript Framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@types/jasmine": "^3.6.10",
|
|
33
33
|
"codecov": "^3.8.1",
|
|
34
34
|
"jasmine": "^3.7.0",
|
|
35
|
-
"karma": "
|
|
35
|
+
"karma": "6.3.16",
|
|
36
36
|
"karma-chrome-launcher": "^3.1.0",
|
|
37
37
|
"karma-coverage": "^2.0.3",
|
|
38
38
|
"karma-jasmine": "^4.0.1",
|
|
39
39
|
"karma-typescript": "^5.5.1",
|
|
40
40
|
"ts-loader": "^9.1.1",
|
|
41
41
|
"typescript": "^4.2.4",
|
|
42
|
-
"webpack": "
|
|
42
|
+
"webpack": "5.76.0",
|
|
43
43
|
"webpack-cli": "^4.6.0"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://www.vsnjs.com",
|
|
@@ -8,6 +8,8 @@ import {ElementQueryNode} from "./ElementQueryNode";
|
|
|
8
8
|
import {LiteralNode} from "./LiteralNode";
|
|
9
9
|
import {DOMObject} from "../DOM/DOMObject";
|
|
10
10
|
import {IndexNode} from "./IndexNode";
|
|
11
|
+
import {ScopeMemberNode} from "./ScopeMemberNode";
|
|
12
|
+
import {RootScopeMemberNode} from "./RootScopeMemberNode";
|
|
11
13
|
|
|
12
14
|
export class ElementAttributeNode extends Node implements TreeNode {
|
|
13
15
|
protected requiresPrep: boolean = true;
|
|
@@ -38,6 +40,7 @@ export class ElementAttributeNode extends Node implements TreeNode {
|
|
|
38
40
|
|
|
39
41
|
async evaluate(scope: Scope, dom: DOM, tag: Tag = null) {
|
|
40
42
|
let tags: TagList;
|
|
43
|
+
|
|
41
44
|
if (this.elementRef instanceof ElementQueryNode) {
|
|
42
45
|
tags = await this.elementRef.evaluate(scope, dom, tag, true);
|
|
43
46
|
} else if (this.elementRef as any instanceof IndexNode) {
|
|
@@ -47,16 +50,34 @@ export class ElementAttributeNode extends Node implements TreeNode {
|
|
|
47
50
|
} else {
|
|
48
51
|
tags = new TagList(indexResult);
|
|
49
52
|
}
|
|
53
|
+
} else if (this.elementRef as any instanceof ScopeMemberNode || this.elementRef as any instanceof RootScopeMemberNode) {
|
|
54
|
+
const scopeEval = await (this.elementRef as any).evaluate(scope, dom, tag, true);
|
|
55
|
+
if (Array.isArray(scopeEval)) {
|
|
56
|
+
tags = scopeEval as any;
|
|
57
|
+
} else {
|
|
58
|
+
tags = new TagList(scopeEval);
|
|
59
|
+
}
|
|
50
60
|
} else if (tag) {
|
|
51
61
|
tags = new TagList(tag)
|
|
52
62
|
} else {
|
|
53
63
|
return;
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
if (tags.length === 1)
|
|
57
|
-
return tags[0]
|
|
66
|
+
if (tags.length === 1) {
|
|
67
|
+
return this.getAttributeScopeValue(tags[0]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return tags.map((tag) => this.getAttributeScopeValue(tag));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async getAttributeScopeValue(tag: Tag | DOMObject): Promise<string> {
|
|
74
|
+
if (!(tag instanceof DOMObject)) {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
58
77
|
|
|
59
|
-
|
|
78
|
+
// Make sure the attribute is being watched
|
|
79
|
+
await tag.watchAttribute(this.attributeName);
|
|
80
|
+
return tag.scope.get(`@${this.attributeName}`) as string;
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
async prepare(scope: Scope, dom: DOM, tag: Tag = null, meta: any = null) {
|
|
@@ -6,6 +6,7 @@ import {TreeNode} from "../AST";
|
|
|
6
6
|
import {Node} from "./Node";
|
|
7
7
|
import {ElementQueryNode} from "./ElementQueryNode";
|
|
8
8
|
import {LiteralNode} from "./LiteralNode";
|
|
9
|
+
import {DOMObject} from "../DOM/DOMObject";
|
|
9
10
|
|
|
10
11
|
export class ElementStyleNode extends Node implements TreeNode {
|
|
11
12
|
protected requiresPrep: boolean = true;
|
|
@@ -44,10 +45,20 @@ export class ElementStyleNode extends Node implements TreeNode {
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
if (tags
|
|
48
|
-
|
|
48
|
+
if (tags instanceof DOMObject)
|
|
49
|
+
tags = new TagList(tags);
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
if (tags.length === 1) {
|
|
52
|
+
return this.getAttributeStyleValue(tags[0]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return tags.map((tag) => this.getAttributeStyleValue(tag));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async getAttributeStyleValue(tag: Tag | DOMObject): Promise<string> {
|
|
59
|
+
// Make sure we're watching the style
|
|
60
|
+
await tag.watchStyle(this.attributeName);
|
|
61
|
+
return tag.scope.get(`$${this.attributeName}`);
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
async prepare(scope: Scope, dom: DOM, tag: Tag = null, meta: any = null) {
|
package/src/DOM/DOMObject.ts
CHANGED
|
@@ -49,11 +49,11 @@ export abstract class DOMObject extends EventDispatcher {
|
|
|
49
49
|
this._scope = scope;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
public watchAttribute(attr: string) {
|
|
52
|
+
public async watchAttribute(attr: string): Promise<any> {
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
public watchStyle(style: string) {
|
|
56
|
+
public async watchStyle(style: string): Promise<any> {
|
|
57
57
|
|
|
58
58
|
}
|
|
59
59
|
|
package/src/EventDispatcher.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type EventDispatcherCallback = (...args: any[]) => any;
|
|
|
30
30
|
|
|
31
31
|
export class EventDispatcher {
|
|
32
32
|
private static sources: EventDispatcher[] = [];
|
|
33
|
+
public static readonly stream: EventDispatcher = new EventDispatcher();
|
|
33
34
|
private readonly _listeners: EventCallbackList;
|
|
34
35
|
private readonly _allListeners: EventCallback[] = [];
|
|
35
36
|
private readonly _relays: EventDispatcher[] = [];
|
|
@@ -137,19 +138,35 @@ export class EventDispatcher {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
noneWithContext(context: any): number {
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
const toRemoveAll: EventCallback[] = [];
|
|
142
|
+
let cnt = 0;
|
|
142
143
|
|
|
143
|
-
for(const cb of this._allListeners) {
|
|
144
|
+
for (const cb of this._allListeners) {
|
|
144
145
|
if(context == cb.context) {
|
|
145
|
-
|
|
146
|
+
toRemoveAll.push(cb);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
for(const
|
|
150
|
+
for (const k in this._listeners) {
|
|
151
|
+
const toRemove: EventCallback[] = [];
|
|
152
|
+
|
|
153
|
+
for (const cb of this._listeners[k]) {
|
|
154
|
+
if(context == cb.context) {
|
|
155
|
+
toRemove.push(cb);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
for (const cb of toRemove) {
|
|
160
|
+
this._listeners[k].splice(this._listeners[k].indexOf(cb), 1);
|
|
161
|
+
cnt++;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (const cb of toRemoveAll) {
|
|
150
166
|
this._allListeners.splice(this._allListeners.indexOf(cb), 1);
|
|
151
167
|
cnt++;
|
|
152
168
|
}
|
|
169
|
+
|
|
153
170
|
return cnt;
|
|
154
171
|
}
|
|
155
172
|
|
|
@@ -180,5 +197,13 @@ export class EventDispatcher {
|
|
|
180
197
|
for (const relay of this._relays) {
|
|
181
198
|
relay.dispatch(event, ...args);
|
|
182
199
|
}
|
|
200
|
+
|
|
201
|
+
if (this === EventDispatcher.stream)
|
|
202
|
+
return;
|
|
203
|
+
|
|
204
|
+
let streamArgs = args;
|
|
205
|
+
if (args.length > 0 && args[0] !== this)
|
|
206
|
+
streamArgs = [this, ...args];
|
|
207
|
+
EventDispatcher.stream.dispatch(event, ...streamArgs);
|
|
183
208
|
}
|
|
184
209
|
}
|
package/src/Tag.ts
CHANGED
|
@@ -753,7 +753,7 @@ export class Tag extends DOMObject {
|
|
|
753
753
|
return this._scope;
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
-
async watchAttribute(attributeName: string) {
|
|
756
|
+
async watchAttribute(attributeName: string): Promise<Attribute | StandardAttribute> {
|
|
757
757
|
if (this.attributes.has(attributeName) && this.attributes.get(attributeName) instanceof StandardAttribute) {
|
|
758
758
|
return this.attributes.get(attributeName);
|
|
759
759
|
}
|
|
@@ -798,6 +798,10 @@ export class Tag extends DOMObject {
|
|
|
798
798
|
this.attributes.clear();
|
|
799
799
|
this._children.forEach(child => child.deconstruct());
|
|
800
800
|
this._children.length = 0;
|
|
801
|
+
if (this._controller) {
|
|
802
|
+
this._controller.deconstruct();
|
|
803
|
+
this._controller = null;
|
|
804
|
+
}
|
|
801
805
|
super.deconstruct();
|
|
802
806
|
}
|
|
803
807
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {Registry} from "../Registry";
|
|
2
|
+
import {Attribute} from "../Attribute";
|
|
3
|
+
import {Scope} from "../Scope";
|
|
4
|
+
import {ScopeReference} from "../Scope/ScopeReference";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@Registry.attribute('vsn-style-var')
|
|
8
|
+
export class StyleVarAttribute extends Attribute {
|
|
9
|
+
public static readonly canDefer: boolean = false;
|
|
10
|
+
protected key?: string;
|
|
11
|
+
protected styleVar?: string;
|
|
12
|
+
protected boundScope?: Scope;
|
|
13
|
+
|
|
14
|
+
public async connect() {
|
|
15
|
+
let scopeKey: string = this.getAttributeValue();
|
|
16
|
+
let ref: ScopeReference;
|
|
17
|
+
try {
|
|
18
|
+
ref = this.tag.scope.getReference(scopeKey);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error('error', e);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.key = await ref.getKey();
|
|
25
|
+
this.styleVar = this.getAttributeBinding();
|
|
26
|
+
this.boundScope = await ref.getScope();
|
|
27
|
+
this.boundScope.on(`change:${this.key}`, this.update, this);
|
|
28
|
+
|
|
29
|
+
await super.connect();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update(e) {
|
|
33
|
+
this.tag.element.style.setProperty(`--${this.styleVar}`, e.value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -25,6 +25,7 @@ export {ServiceAttribute} from "./ServiceAttribute";
|
|
|
25
25
|
export {SetAttribute} from "./SetAttribute";
|
|
26
26
|
export {StandardAttribute} from "./StandardAttribute";
|
|
27
27
|
export {StyleAttribute} from "./StyleAttribute";
|
|
28
|
+
export {StyleVarAttribute} from "./StyleVarAttribute";
|
|
28
29
|
export {TemplateAttribute} from "./TemplateAttribute";
|
|
29
30
|
export {TypeAttribute} from "./TypeAttribute";
|
|
30
31
|
export {XHRAttribute} from "./XHRAttribute";
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.1.
|
|
1
|
+
export const VERSION = '0.1.128';
|
|
2
2
|
|