@microsoft/fast-html 1.0.0-alpha.19 → 1.0.0-alpha.20
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/README.md +3 -19
- package/dist/dts/components/observer-map.d.ts +3 -120
- package/dist/dts/components/schema.d.ts +23 -15
- package/dist/dts/components/template.d.ts +1 -5
- package/dist/dts/components/utilities.d.ts +33 -69
- package/dist/esm/components/observer-map.js +10 -512
- package/dist/esm/components/observer-map.spec.js +5 -599
- package/dist/esm/components/schema.js +39 -20
- package/dist/esm/components/schema.spec.js +9 -0
- package/dist/esm/components/template.js +31 -50
- package/dist/esm/components/utilities.js +202 -179
- package/dist/esm/components/utilities.spec.js +6 -29
- package/dist/esm/fixtures/repeat/main.js +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/fast-html.api.json +13 -126
- package/dist/fast-html.d.ts +118 -150
- package/dist/fast-html.untrimmed.d.ts +118 -150
- package/package.json +2 -3
- package/dist/dts/fixtures/partial/main.d.ts +0 -1
- package/dist/dts/fixtures/partial/partial.spec.d.ts +0 -1
- package/dist/esm/fixtures/partial/main.js +0 -32
- package/dist/esm/fixtures/partial/partial.spec.js +0 -14
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// The context, in most cases the array property e.g. users
|
|
2
|
-
const fastContextMetaData = "$fast_context";
|
|
2
|
+
export const fastContextMetaData = "$fast_context";
|
|
3
3
|
// The list of contexts preceeding this context, the first of which should be the root property
|
|
4
|
-
const fastContextsMetaData = "$fast_parent_contexts";
|
|
5
|
-
const defsPropertyName = "$defs";
|
|
6
|
-
const refPropertyName = "$ref";
|
|
4
|
+
export const fastContextsMetaData = "$fast_parent_contexts";
|
|
5
|
+
export const defsPropertyName = "$defs";
|
|
6
|
+
export const refPropertyName = "$ref";
|
|
7
7
|
/**
|
|
8
8
|
* A constructed JSON schema from a template
|
|
9
9
|
*/
|
|
@@ -20,7 +20,7 @@ export class Schema {
|
|
|
20
20
|
* @param config RegisterPathConfig
|
|
21
21
|
*/
|
|
22
22
|
addPath(config) {
|
|
23
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c;
|
|
24
24
|
const splitPath = this.getSplitPath(config.pathConfig.path);
|
|
25
25
|
let schema = this.jsonSchemaMap.get(config.rootPropertyName);
|
|
26
26
|
// Create a root level property JSON
|
|
@@ -31,27 +31,39 @@ export class Schema {
|
|
|
31
31
|
switch (config.pathConfig.type) {
|
|
32
32
|
case "default":
|
|
33
33
|
case "access": {
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (splitPath.length > 1) {
|
|
35
|
+
if (config.pathConfig.currentContext === null) {
|
|
36
|
+
this.addPropertiesToAnObject(schema, splitPath.slice(1), config.pathConfig.currentContext);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (!((_a = schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[splitPath[0]])) {
|
|
40
|
+
schema[defsPropertyName] = {
|
|
41
|
+
[splitPath[0]]: {},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
this.addPropertiesToAContext(schema[defsPropertyName][splitPath[0]], splitPath.slice(1), config.pathConfig.currentContext);
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
break;
|
|
41
48
|
}
|
|
42
49
|
case "repeat": {
|
|
43
|
-
this.addContext(schema, splitPath
|
|
50
|
+
this.addContext(schema, splitPath.at(-1), // example items
|
|
44
51
|
config.pathConfig.currentContext, // example item
|
|
45
52
|
config.pathConfig.parentContext);
|
|
46
53
|
if (splitPath.length > 2) {
|
|
47
54
|
let updatedSchema = schema;
|
|
48
|
-
|
|
55
|
+
const hasParentContext = !!config.pathConfig.parentContext;
|
|
56
|
+
if (hasParentContext) {
|
|
49
57
|
updatedSchema = this.addPropertiesToAnObject((_b = schema[defsPropertyName]) === null || _b === void 0 ? void 0 : _b[config.pathConfig.parentContext], splitPath.slice(1, -1), config.pathConfig.parentContext);
|
|
50
58
|
}
|
|
51
|
-
this.addPropertiesToAnObject(updatedSchema, splitPath.slice(
|
|
59
|
+
this.addPropertiesToAnObject(updatedSchema, hasParentContext ? splitPath.slice(2) : splitPath.slice(1), config.pathConfig.currentContext, "array");
|
|
52
60
|
}
|
|
53
61
|
else if (splitPath.length > 1) {
|
|
54
|
-
|
|
62
|
+
let schemaDefinition;
|
|
63
|
+
if (config.pathConfig.parentContext) {
|
|
64
|
+
schemaDefinition = (_c = schema === null || schema === void 0 ? void 0 : schema[defsPropertyName]) === null || _c === void 0 ? void 0 : _c[config.pathConfig.parentContext];
|
|
65
|
+
}
|
|
66
|
+
this.addPropertiesToAnObject(schemaDefinition !== null && schemaDefinition !== void 0 ? schemaDefinition : schema, splitPath.slice(1), config.pathConfig.currentContext, "array");
|
|
55
67
|
}
|
|
56
68
|
else {
|
|
57
69
|
schema.type = "array";
|
|
@@ -70,6 +82,13 @@ export class Schema {
|
|
|
70
82
|
var _a;
|
|
71
83
|
return (_a = this.jsonSchemaMap.get(rootPropertyName)) !== null && _a !== void 0 ? _a : null;
|
|
72
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets root properties
|
|
87
|
+
* @returns IterableIterator<string>
|
|
88
|
+
*/
|
|
89
|
+
getRootProperties() {
|
|
90
|
+
return this.jsonSchemaMap.keys();
|
|
91
|
+
}
|
|
73
92
|
/**
|
|
74
93
|
* Get a path split into property names
|
|
75
94
|
* @param path The dot syntax path e.g. a.b.c
|
|
@@ -105,10 +124,10 @@ export class Schema {
|
|
|
105
124
|
*/
|
|
106
125
|
addPropertiesToAContext(schema, splitPath, context) {
|
|
107
126
|
schema.type = "object";
|
|
108
|
-
if (schema.properties) {
|
|
127
|
+
if (schema.properties && !schema.properties[splitPath[0]]) {
|
|
109
128
|
schema.properties[splitPath[0]] = {};
|
|
110
129
|
}
|
|
111
|
-
else {
|
|
130
|
+
else if (!schema.properties) {
|
|
112
131
|
schema.properties = {
|
|
113
132
|
[splitPath[0]]: {},
|
|
114
133
|
};
|
|
@@ -126,15 +145,15 @@ export class Schema {
|
|
|
126
145
|
*/
|
|
127
146
|
addPropertiesToAnObject(schema, splitPath, context, type = "object") {
|
|
128
147
|
schema.type = "object";
|
|
129
|
-
if (schema.properties) {
|
|
148
|
+
if (schema.properties && !schema.properties[splitPath[0]]) {
|
|
130
149
|
schema.properties[splitPath[0]] = {};
|
|
131
150
|
}
|
|
132
|
-
else {
|
|
151
|
+
else if (!schema.properties) {
|
|
133
152
|
schema.properties = {
|
|
134
153
|
[splitPath[0]]: {},
|
|
135
154
|
};
|
|
136
155
|
}
|
|
137
|
-
if (
|
|
156
|
+
if (type === "object" && splitPath.length > 1) {
|
|
138
157
|
return this.addPropertiesToAnObject(schema.properties[splitPath[0]], splitPath.slice(1), context, type);
|
|
139
158
|
}
|
|
140
159
|
else if (type === "array") {
|
|
@@ -190,7 +209,7 @@ export class Schema {
|
|
|
190
209
|
if (parentContext === null) {
|
|
191
210
|
return [null, ...contexts];
|
|
192
211
|
}
|
|
193
|
-
const parentParentContext = (_a = schema === null || schema === void 0 ? void 0 : schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[parentContext]
|
|
212
|
+
const parentParentContext = (_a = schema === null || schema === void 0 ? void 0 : schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[parentContext][fastContextsMetaData];
|
|
194
213
|
return this.getParentContexts(schema, parentParentContext.at(-1), [parentContext, ...contexts]);
|
|
195
214
|
}
|
|
196
215
|
}
|
|
@@ -17,6 +17,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
17
17
|
type: "default",
|
|
18
18
|
path: "a",
|
|
19
19
|
currentContext: null,
|
|
20
|
+
parentContext: null,
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
const schemaA = schema.getSchema("a");
|
|
@@ -32,6 +33,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
32
33
|
type: "default",
|
|
33
34
|
path: "a.b",
|
|
34
35
|
currentContext: null,
|
|
36
|
+
parentContext: null,
|
|
35
37
|
},
|
|
36
38
|
});
|
|
37
39
|
let schemaA = schema.getSchema("a");
|
|
@@ -43,6 +45,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
43
45
|
type: "default",
|
|
44
46
|
path: "a.b.c",
|
|
45
47
|
currentContext: null,
|
|
48
|
+
parentContext: null,
|
|
46
49
|
},
|
|
47
50
|
});
|
|
48
51
|
schemaA = schema.getSchema("a");
|
|
@@ -81,6 +84,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
81
84
|
type: "default",
|
|
82
85
|
path: "a",
|
|
83
86
|
currentContext: null,
|
|
87
|
+
parentContext: null,
|
|
84
88
|
},
|
|
85
89
|
});
|
|
86
90
|
schema.addPath({
|
|
@@ -109,6 +113,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
109
113
|
type: "default",
|
|
110
114
|
path: "a",
|
|
111
115
|
currentContext: null,
|
|
116
|
+
parentContext: null,
|
|
112
117
|
},
|
|
113
118
|
});
|
|
114
119
|
schema.addPath({
|
|
@@ -126,6 +131,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
126
131
|
type: "access",
|
|
127
132
|
path: "item.b",
|
|
128
133
|
currentContext: "item",
|
|
134
|
+
parentContext: null,
|
|
129
135
|
},
|
|
130
136
|
});
|
|
131
137
|
const schemaA = schema.getSchema("a");
|
|
@@ -146,6 +152,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
146
152
|
type: "default",
|
|
147
153
|
path: "a",
|
|
148
154
|
currentContext: null,
|
|
155
|
+
parentContext: null,
|
|
149
156
|
},
|
|
150
157
|
});
|
|
151
158
|
schema.addPath({
|
|
@@ -193,6 +200,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
193
200
|
type: "access",
|
|
194
201
|
path: "user.a.b",
|
|
195
202
|
currentContext: "user",
|
|
203
|
+
parentContext: null,
|
|
196
204
|
},
|
|
197
205
|
});
|
|
198
206
|
schema.addPath({
|
|
@@ -210,6 +218,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
210
218
|
type: "access",
|
|
211
219
|
path: "post.c.d",
|
|
212
220
|
currentContext: "post",
|
|
221
|
+
parentContext: null,
|
|
213
222
|
},
|
|
214
223
|
});
|
|
215
224
|
schema.addPath({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __awaiter, __decorate, __metadata } from "tslib";
|
|
2
2
|
import { attr, elements, FAST, FASTElement, FASTElementDefinition, fastElementRegistry, HydratableElementController, ViewTemplate, } from "@microsoft/fast-element";
|
|
3
3
|
import "@microsoft/fast-element/install-hydratable-view-templates.js";
|
|
4
|
-
import { bindingResolver,
|
|
4
|
+
import { bindingResolver, getExpressionChain, getNextBehavior, getRootPropertyName, resolveWhen, transformInnerHTML, } from "./utilities.js";
|
|
5
5
|
import { ObserverMap } from "./observer-map.js";
|
|
6
|
+
import { Schema } from "./schema.js";
|
|
6
7
|
/**
|
|
7
8
|
* The <f-template> custom element that will provide view logic to the element
|
|
8
9
|
*/
|
|
@@ -42,6 +43,7 @@ class TemplateElement extends FASTElement {
|
|
|
42
43
|
connectedCallback() {
|
|
43
44
|
super.connectedCallback();
|
|
44
45
|
if (typeof this.name === "string") {
|
|
46
|
+
this.schema = new Schema(this.name);
|
|
45
47
|
FASTElementDefinition.registerAsync(this.name).then((value) => __awaiter(this, void 0, void 0, function* () {
|
|
46
48
|
var _a, _b, _c, _d;
|
|
47
49
|
if (!((_a = TemplateElement.elementOptions) === null || _a === void 0 ? void 0 : _a[this.name])) {
|
|
@@ -49,15 +51,14 @@ class TemplateElement extends FASTElement {
|
|
|
49
51
|
}
|
|
50
52
|
if (((_b = TemplateElement.elementOptions[this.name]) === null || _b === void 0 ? void 0 : _b.observerMap) ===
|
|
51
53
|
"all") {
|
|
52
|
-
this.observerMap = new ObserverMap(value.prototype);
|
|
54
|
+
this.observerMap = new ObserverMap(value.prototype, this.schema);
|
|
53
55
|
}
|
|
54
56
|
const registeredFastElement = fastElementRegistry.getByType(value);
|
|
55
57
|
const template = this.getElementsByTagName("template").item(0);
|
|
56
58
|
if (template) {
|
|
57
59
|
const innerHTML = yield transformInnerHTML(this.innerHTML);
|
|
58
|
-
yield this.resolveAllPartials(innerHTML);
|
|
59
60
|
// Cache paths during template processing (pass undefined if observerMap is not available)
|
|
60
|
-
const { strings, values } = yield this.resolveStringsAndValues(innerHTML, false, null, 0, this.observerMap);
|
|
61
|
+
const { strings, values } = yield this.resolveStringsAndValues(null, innerHTML, false, null, 0, this.schema, this.observerMap);
|
|
61
62
|
// Define the root properties cached in the observer map as observable (only if observerMap exists)
|
|
62
63
|
(_c = this.observerMap) === null || _c === void 0 ? void 0 : _c.defineProperties();
|
|
63
64
|
if (registeredFastElement) {
|
|
@@ -80,11 +81,11 @@ class TemplateElement extends FASTElement {
|
|
|
80
81
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
81
82
|
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
82
83
|
*/
|
|
83
|
-
resolveStringsAndValues(innerHTML, self = false, parentContext, level, observerMap) {
|
|
84
|
+
resolveStringsAndValues(rootPropertyName, innerHTML, self = false, parentContext, level, schema, observerMap) {
|
|
84
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
86
|
const strings = [];
|
|
86
87
|
const values = []; // these can be bindings, directives, etc.
|
|
87
|
-
yield this.resolveInnerHTML(innerHTML, strings, values, self, parentContext, level, observerMap);
|
|
88
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self, parentContext, level, schema, observerMap);
|
|
88
89
|
strings.raw = strings.map(value => String.raw({ raw: value }));
|
|
89
90
|
return {
|
|
90
91
|
strings,
|
|
@@ -108,15 +109,14 @@ class TemplateElement extends FASTElement {
|
|
|
108
109
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
109
110
|
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
110
111
|
*/
|
|
111
|
-
resolveTemplateDirective(behaviorConfig, externalValues, innerHTML, self = false, parentContext, level, observerMap) {
|
|
112
|
-
var _a;
|
|
112
|
+
resolveTemplateDirective(rootPropertyName, behaviorConfig, externalValues, innerHTML, self = false, parentContext, level, schema, observerMap) {
|
|
113
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
switch (behaviorConfig.name) {
|
|
115
115
|
case "when": {
|
|
116
116
|
const { when } = yield import("@microsoft/fast-element");
|
|
117
117
|
const expressionChain = getExpressionChain(behaviorConfig.value);
|
|
118
|
-
const whenLogic = resolveWhen(
|
|
119
|
-
const { strings, values } = yield this.resolveStringsAndValues(innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), self, parentContext, level, observerMap);
|
|
118
|
+
const whenLogic = resolveWhen(rootPropertyName, expressionChain, parentContext, level, schema);
|
|
119
|
+
const { strings, values } = yield this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), self, parentContext, level, schema, observerMap);
|
|
120
120
|
externalValues.push(when(whenLogic, this.resolveTemplateOrBehavior(strings, values)));
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
@@ -124,24 +124,12 @@ class TemplateElement extends FASTElement {
|
|
|
124
124
|
const valueAttr = behaviorConfig.value.split(" "); // syntax {{x in y}}
|
|
125
125
|
const updatedLevel = level + 1;
|
|
126
126
|
const { repeat } = yield import("@microsoft/fast-element");
|
|
127
|
-
|
|
128
|
-
const
|
|
127
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name);
|
|
128
|
+
const binding = bindingResolver(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name, schema, valueAttr[0], level);
|
|
129
|
+
const { strings, values } = yield this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true, valueAttr[0], updatedLevel, schema, observerMap);
|
|
129
130
|
externalValues.push(repeat((x, c) => binding(x, c), this.resolveTemplateOrBehavior(strings, values)));
|
|
130
131
|
break;
|
|
131
132
|
}
|
|
132
|
-
case "apply": {
|
|
133
|
-
const openingTag = innerHTML.slice(behaviorConfig.openingTagStartIndex, behaviorConfig.openingTagEndIndex);
|
|
134
|
-
const partial = (_a = openingTag
|
|
135
|
-
.split(" ")
|
|
136
|
-
.find(tagPart => {
|
|
137
|
-
return tagPart.startsWith("partial");
|
|
138
|
-
})) === null || _a === void 0 ? void 0 : _a.split('"')[1];
|
|
139
|
-
if (partial) {
|
|
140
|
-
const { when } = yield import("@microsoft/fast-element");
|
|
141
|
-
const binding = bindingResolver(behaviorConfig.value, self, parentContext, "access", observerMap !== null && observerMap !== void 0 ? observerMap : null, null, level);
|
|
142
|
-
externalValues.push(when((x, c) => binding(x, c), () => this.partials[partial]));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
133
|
}
|
|
146
134
|
});
|
|
147
135
|
}
|
|
@@ -194,16 +182,18 @@ class TemplateElement extends FASTElement {
|
|
|
194
182
|
* @param behaviorConfig - The binding behavior configuration object.
|
|
195
183
|
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
196
184
|
*/
|
|
197
|
-
resolveDataBinding(innerHTML, strings, values, self = false, behaviorConfig, parentContext, level, observerMap) {
|
|
185
|
+
resolveDataBinding(rootPropertyName, innerHTML, strings, values, self = false, behaviorConfig, parentContext, level, schema, observerMap) {
|
|
198
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
187
|
switch (behaviorConfig.subtype) {
|
|
200
188
|
case "content": {
|
|
201
189
|
strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
|
|
190
|
+
const type = "access";
|
|
202
191
|
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
203
|
-
|
|
192
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
193
|
+
const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
204
194
|
const contentBinding = (x, c) => binding(x, c);
|
|
205
195
|
values.push(contentBinding);
|
|
206
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, observerMap);
|
|
196
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
207
197
|
break;
|
|
208
198
|
}
|
|
209
199
|
case "attribute": {
|
|
@@ -215,29 +205,33 @@ class TemplateElement extends FASTElement {
|
|
|
215
205
|
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex -
|
|
216
206
|
(closingParenthesis - openingParenthesis) -
|
|
217
207
|
1);
|
|
208
|
+
const type = "event";
|
|
209
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
218
210
|
const arg = bindingHTML.slice(openingParenthesis + 1, closingParenthesis);
|
|
219
|
-
const binding = bindingResolver(
|
|
211
|
+
const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
220
212
|
const attributeBinding = (x, c) => binding(x, c).bind(x)(...(arg === "e" ? [c.event] : []), ...(arg !== "e" && arg !== ""
|
|
221
213
|
? [
|
|
222
|
-
bindingResolver(
|
|
214
|
+
bindingResolver(rootPropertyName, arg, parentContext, type, schema, parentContext, level)(x, c),
|
|
223
215
|
]
|
|
224
216
|
: []));
|
|
225
217
|
values.push(attributeBinding);
|
|
226
218
|
}
|
|
227
219
|
else {
|
|
228
220
|
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
229
|
-
const
|
|
221
|
+
const type = "access";
|
|
222
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
223
|
+
const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
230
224
|
const attributeBinding = (x, c) => binding(x, c);
|
|
231
225
|
values.push(attributeBinding);
|
|
232
226
|
}
|
|
233
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, observerMap);
|
|
227
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
234
228
|
break;
|
|
235
229
|
}
|
|
236
230
|
case "attributeDirective": {
|
|
237
231
|
strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex - behaviorConfig.name.length - 4));
|
|
238
232
|
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
239
233
|
yield this.resolveAttributeDirective(behaviorConfig.name, propName, values);
|
|
240
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self, parentContext, level, observerMap);
|
|
234
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
241
235
|
break;
|
|
242
236
|
}
|
|
243
237
|
}
|
|
@@ -251,7 +245,7 @@ class TemplateElement extends FASTElement {
|
|
|
251
245
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
252
246
|
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
253
247
|
*/
|
|
254
|
-
resolveInnerHTML(innerHTML, strings, values, self = false, parentContext, level, observerMap) {
|
|
248
|
+
resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self = false, parentContext, level, schema, observerMap) {
|
|
255
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
250
|
const behaviorConfig = getNextBehavior(innerHTML);
|
|
257
251
|
if (behaviorConfig === null) {
|
|
@@ -260,32 +254,19 @@ class TemplateElement extends FASTElement {
|
|
|
260
254
|
else {
|
|
261
255
|
switch (behaviorConfig.type) {
|
|
262
256
|
case "dataBinding": {
|
|
263
|
-
yield this.resolveDataBinding(innerHTML, strings, values, self, behaviorConfig, parentContext, level, observerMap);
|
|
257
|
+
yield this.resolveDataBinding(rootPropertyName, innerHTML, strings, values, self, behaviorConfig, parentContext, level, schema, observerMap);
|
|
264
258
|
break;
|
|
265
259
|
}
|
|
266
260
|
case "templateDirective": {
|
|
267
261
|
strings.push(innerHTML.slice(0, behaviorConfig.openingTagStartIndex));
|
|
268
|
-
yield this.resolveTemplateDirective(behaviorConfig, values, innerHTML, self, parentContext, level, observerMap);
|
|
269
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self, parentContext, level, observerMap);
|
|
262
|
+
yield this.resolveTemplateDirective(rootPropertyName, behaviorConfig, values, innerHTML, self, parentContext, level, schema, observerMap);
|
|
263
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
270
264
|
break;
|
|
271
265
|
}
|
|
272
266
|
}
|
|
273
267
|
}
|
|
274
268
|
});
|
|
275
269
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Resolve all partial templates
|
|
278
|
-
* @param unresolvedInnerHTML - The innerHTML.
|
|
279
|
-
*/
|
|
280
|
-
resolveAllPartials(unresolvedInnerHTML) {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
const allPartials = Object.entries(getAllPartials(unresolvedInnerHTML));
|
|
283
|
-
for (let i = 0, partialLength = allPartials.length; i < partialLength; i++) {
|
|
284
|
-
const { strings, values } = yield this.resolveStringsAndValues(allPartials[i][1].innerHTML, undefined, null, 0, this.observerMap);
|
|
285
|
-
this.partials[allPartials[i][0]] = this.resolveTemplateOrBehavior(strings, values);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
270
|
}
|
|
290
271
|
/**
|
|
291
272
|
* A dictionary of custom element options
|