@microsoft/fast-html 1.0.0-alpha.3 → 1.0.0-alpha.31
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 +255 -18
- package/dist/dts/components/element.d.ts +10 -0
- package/dist/dts/components/index.d.ts +3 -1
- package/dist/dts/components/observer-map.d.ts +26 -0
- package/dist/dts/components/schema.d.ts +144 -0
- package/dist/dts/components/template.d.ts +83 -7
- package/dist/dts/components/utilities.d.ts +109 -18
- package/dist/dts/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.d.ts +1 -0
- package/dist/dts/fixtures/lifecycle-callbacks/main.d.ts +5 -0
- package/dist/dts/fixtures/observer-map/main.d.ts +1 -0
- package/dist/dts/fixtures/observer-map/observer-map.spec.d.ts +1 -0
- package/dist/dts/index.d.ts +1 -1
- package/dist/esm/components/element.js +28 -0
- package/dist/esm/components/index.js +3 -1
- package/dist/esm/components/observer-map.js +53 -0
- package/dist/esm/components/observer-map.spec.js +19 -0
- package/dist/esm/components/schema.js +250 -0
- package/dist/esm/components/schema.spec.js +485 -0
- package/dist/esm/components/template.js +199 -111
- package/dist/esm/components/utilities.js +741 -43
- package/dist/esm/components/utilities.spec.js +317 -44
- package/dist/esm/fixtures/attribute/main.js +3 -2
- package/dist/esm/fixtures/binding/binding.spec.js +6 -0
- package/dist/esm/fixtures/binding/main.js +13 -2
- package/dist/esm/fixtures/children/children.spec.js +4 -0
- package/dist/esm/fixtures/children/main.js +3 -2
- package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +109 -2
- package/dist/esm/fixtures/dot-syntax/main.js +30 -4
- package/dist/esm/fixtures/event/event.spec.js +28 -5
- package/dist/esm/fixtures/event/main.js +21 -5
- package/dist/esm/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.js +166 -0
- package/dist/esm/fixtures/lifecycle-callbacks/main.js +126 -0
- package/dist/esm/fixtures/observer-map/main.js +375 -0
- package/dist/esm/fixtures/observer-map/observer-map.spec.js +251 -0
- package/dist/esm/fixtures/ref/main.js +3 -2
- package/dist/esm/fixtures/ref/ref.spec.js +2 -6
- package/dist/esm/fixtures/repeat/main.js +27 -2
- package/dist/esm/fixtures/repeat/repeat.spec.js +16 -6
- package/dist/esm/fixtures/slotted/main.js +15 -4
- package/dist/esm/fixtures/slotted/slotted.spec.js +18 -19
- package/dist/esm/fixtures/when/main.js +139 -2
- package/dist/esm/fixtures/when/when.spec.js +64 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/fast-html.api.json +333 -0
- package/dist/fast-html.d.ts +282 -6
- package/dist/fast-html.untrimmed.d.ts +282 -6
- package/package.json +12 -7
- package/rules/attribute-directives.yml +38 -0
- package/rules/call-expression-with-event-argument.yml +41 -0
- package/rules/member-expression.yml +33 -0
- package/rules/tag-function-to-template-literal.yml +16 -0
- package/dist/esm/fixtures/partial/main.js +0 -31
- package/dist/esm/fixtures/partial/partial.spec.js +0 -14
- /package/dist/dts/{fixtures/partial/main.d.ts → components/observer-map.spec.d.ts} +0 -0
- /package/dist/dts/{fixtures/partial/partial.spec.d.ts → components/schema.spec.d.ts} +0 -0
|
@@ -1,48 +1,120 @@
|
|
|
1
1
|
import { __awaiter, __decorate, __metadata } from "tslib";
|
|
2
|
-
import { attr, FAST, FASTElement, fastElementRegistry, ViewTemplate, } from "@microsoft/fast-element";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { attr, children, elements, FAST, FASTElement, FASTElementDefinition, fastElementRegistry, HydratableElementController, ref, repeat, slotted, ViewTemplate, when, } from "@microsoft/fast-element";
|
|
3
|
+
import "@microsoft/fast-element/install-hydratable-view-templates.js";
|
|
4
|
+
import { ObserverMap } from "./observer-map.js";
|
|
5
|
+
import { Schema } from "./schema.js";
|
|
6
|
+
import { bindingResolver, getExpressionChain, getNextBehavior, getRootPropertyName, resolveWhen, transformInnerHTML, } from "./utilities.js";
|
|
7
|
+
/**
|
|
8
|
+
* Values for the observerMap element option.
|
|
9
|
+
*/
|
|
10
|
+
export const ObserverMapOption = {
|
|
11
|
+
all: "all",
|
|
12
|
+
};
|
|
5
13
|
/**
|
|
6
14
|
* The <f-template> custom element that will provide view logic to the element
|
|
7
15
|
*/
|
|
8
16
|
class TemplateElement extends FASTElement {
|
|
17
|
+
/**
|
|
18
|
+
* Configure lifecycle callbacks for hydration events.
|
|
19
|
+
*
|
|
20
|
+
* @param callbacks - Lifecycle callbacks to configure.
|
|
21
|
+
* @returns The {@link TemplateElement} class.
|
|
22
|
+
*/
|
|
23
|
+
static config(callbacks) {
|
|
24
|
+
TemplateElement.lifecycleCallbacks = callbacks;
|
|
25
|
+
// Pass the hydration-specific callbacks to HydratableElementController
|
|
26
|
+
HydratableElementController.config(Object.assign({}, callbacks));
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Set options for custom elements.
|
|
31
|
+
*
|
|
32
|
+
* @param elementOptions - A dictionary of custom element options
|
|
33
|
+
* @returns The TemplateElement class.
|
|
34
|
+
*/
|
|
35
|
+
static options(elementOptions = {}) {
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const key in elementOptions) {
|
|
38
|
+
const value = elementOptions[key];
|
|
39
|
+
result[key] = {
|
|
40
|
+
observerMap: value.observerMap,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
TemplateElement.elementOptions = result;
|
|
44
|
+
HydratableElementController.install();
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
9
47
|
constructor() {
|
|
10
|
-
super(
|
|
11
|
-
|
|
48
|
+
super();
|
|
49
|
+
// Ensure elementOptions is initialized if it's empty
|
|
50
|
+
if (!TemplateElement.elementOptions ||
|
|
51
|
+
Object.keys(TemplateElement.elementOptions).length === 0) {
|
|
52
|
+
TemplateElement.options();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Set options for a custom element
|
|
57
|
+
* @param name - The name of the custom element to set options for.
|
|
58
|
+
*/
|
|
59
|
+
static setOptions(name) {
|
|
60
|
+
if (!TemplateElement.elementOptions[name]) {
|
|
61
|
+
TemplateElement.elementOptions[name] = TemplateElement.defaultElementOptions;
|
|
62
|
+
}
|
|
12
63
|
}
|
|
13
64
|
connectedCallback() {
|
|
14
65
|
super.connectedCallback();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.then((value) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const registeredFastElement = fastElementRegistry.getByType(value);
|
|
20
|
-
const template = this.getElementsByTagName("template").item(0);
|
|
21
|
-
if (template) {
|
|
22
|
-
yield this.resolveAllPartials(this.innerHTML);
|
|
23
|
-
const { strings, values } = yield this.resolveStringsAndValues(this.innerHTML);
|
|
24
|
-
if (registeredFastElement) {
|
|
25
|
-
// all new elements will get the updated template
|
|
26
|
-
registeredFastElement.template =
|
|
27
|
-
this.resolveTemplateOrBehavior(strings, values);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
throw FAST.error(2000 /* Message.noTemplateProvided */, { name: this.name });
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
66
|
+
const name = this.name;
|
|
67
|
+
if (typeof name !== "string") {
|
|
68
|
+
return;
|
|
34
69
|
}
|
|
70
|
+
this.schema = new Schema(name);
|
|
71
|
+
FASTElementDefinition.registerAsync(name).then((value) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
73
|
+
(_b = (_a = TemplateElement.lifecycleCallbacks).elementDidRegister) === null || _b === void 0 ? void 0 : _b.call(_a, name);
|
|
74
|
+
if (!((_c = TemplateElement.elementOptions) === null || _c === void 0 ? void 0 : _c[name])) {
|
|
75
|
+
TemplateElement.setOptions(name);
|
|
76
|
+
}
|
|
77
|
+
if (((_d = TemplateElement.elementOptions[name]) === null || _d === void 0 ? void 0 : _d.observerMap) === "all") {
|
|
78
|
+
this.observerMap = new ObserverMap(value.prototype, this.schema);
|
|
79
|
+
}
|
|
80
|
+
const registeredFastElement = fastElementRegistry.getByType(value);
|
|
81
|
+
const template = this.getElementsByTagName("template").item(0);
|
|
82
|
+
if (template) {
|
|
83
|
+
// Callback: Before template has been evaluated and assigned
|
|
84
|
+
(_f = (_e = TemplateElement.lifecycleCallbacks).templateWillUpdate) === null || _f === void 0 ? void 0 : _f.call(_e, name);
|
|
85
|
+
const innerHTML = transformInnerHTML(this.innerHTML);
|
|
86
|
+
// Cache paths during template processing (pass undefined if observerMap is not available)
|
|
87
|
+
const { strings, values } = yield this.resolveStringsAndValues(null, innerHTML, false, null, 0, this.schema, this.observerMap);
|
|
88
|
+
// Define the root properties cached in the observer map as observable (only if observerMap exists)
|
|
89
|
+
(_g = this.observerMap) === null || _g === void 0 ? void 0 : _g.defineProperties();
|
|
90
|
+
if (registeredFastElement) {
|
|
91
|
+
// Attach lifecycle callbacks to the definition before assigning template
|
|
92
|
+
// This allows the Observable notification to trigger the callbacks
|
|
93
|
+
registeredFastElement.lifecycleCallbacks = {
|
|
94
|
+
templateDidUpdate: TemplateElement.lifecycleCallbacks.templateDidUpdate,
|
|
95
|
+
elementDidDefine: TemplateElement.lifecycleCallbacks.elementDidDefine,
|
|
96
|
+
};
|
|
97
|
+
// All new elements will get the updated template
|
|
98
|
+
// This assignment triggers the Observable notification → callbacks fire
|
|
99
|
+
registeredFastElement.template = this.resolveTemplateOrBehavior(strings, values);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw FAST.error(2000 /* Message.noTemplateProvided */, { name: this.name });
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
35
106
|
}
|
|
36
107
|
/**
|
|
37
108
|
* Resolve strings and values from an innerHTML string
|
|
38
109
|
* @param innerHTML - The innerHTML.
|
|
39
110
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
111
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
40
112
|
*/
|
|
41
|
-
resolveStringsAndValues(innerHTML, self = false) {
|
|
113
|
+
resolveStringsAndValues(rootPropertyName, innerHTML, self = false, parentContext, level, schema, observerMap) {
|
|
42
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
115
|
const strings = [];
|
|
44
116
|
const values = []; // these can be bindings, directives, etc.
|
|
45
|
-
yield this.resolveInnerHTML(innerHTML, strings, values, self);
|
|
117
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self, parentContext, level, schema, observerMap);
|
|
46
118
|
strings.raw = strings.map(value => String.raw({ raw: value }));
|
|
47
119
|
return {
|
|
48
120
|
strings,
|
|
@@ -56,44 +128,34 @@ class TemplateElement extends FASTElement {
|
|
|
56
128
|
* @param values - The interpreted values.
|
|
57
129
|
*/
|
|
58
130
|
resolveTemplateOrBehavior(strings, values) {
|
|
59
|
-
return ViewTemplate.create(strings, values
|
|
131
|
+
return ViewTemplate.create(strings, values);
|
|
60
132
|
}
|
|
61
133
|
/**
|
|
62
134
|
* Resolve a template directive
|
|
63
135
|
* @param behaviorConfig - The directive behavior configuration object.
|
|
64
136
|
* @param externalValues - The interpreted values from the parent.
|
|
65
137
|
* @param innerHTML - The innerHTML.
|
|
138
|
+
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
139
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
66
140
|
*/
|
|
67
|
-
resolveTemplateDirective(behaviorConfig, externalValues, innerHTML, self = false) {
|
|
68
|
-
var _a;
|
|
141
|
+
resolveTemplateDirective(rootPropertyName, behaviorConfig, externalValues, innerHTML, self = false, parentContext, level, schema, observerMap) {
|
|
69
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
143
|
switch (behaviorConfig.name) {
|
|
71
|
-
case "when":
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
144
|
+
case "when": {
|
|
145
|
+
const expressionChain = getExpressionChain(behaviorConfig.value);
|
|
146
|
+
const whenLogic = resolveWhen(rootPropertyName, expressionChain, parentContext, level, schema);
|
|
147
|
+
const { strings, values } = yield this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), self, parentContext, level, schema, observerMap);
|
|
148
|
+
externalValues.push(when(whenLogic, this.resolveTemplateOrBehavior(strings, values)));
|
|
77
149
|
break;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
150
|
+
}
|
|
151
|
+
case "repeat": {
|
|
152
|
+
const valueAttr = behaviorConfig.value.split(" "); // syntax {{x in y}}
|
|
153
|
+
const updatedLevel = level + 1;
|
|
154
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name);
|
|
155
|
+
const binding = bindingResolver(null, rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name, schema, valueAttr[0], level);
|
|
156
|
+
const { strings, values } = yield this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true, valueAttr[0], updatedLevel, schema, observerMap);
|
|
157
|
+
externalValues.push(repeat((x, c) => binding(x, c), this.resolveTemplateOrBehavior(strings, values)));
|
|
85
158
|
break;
|
|
86
|
-
case "apply": {
|
|
87
|
-
const openingTag = innerHTML.slice(behaviorConfig.openingTagStartIndex, behaviorConfig.openingTagEndIndex);
|
|
88
|
-
const partial = (_a = openingTag
|
|
89
|
-
.split(" ")
|
|
90
|
-
.find(tagPart => {
|
|
91
|
-
return tagPart.startsWith("partial");
|
|
92
|
-
})) === null || _a === void 0 ? void 0 : _a.split('"')[1];
|
|
93
|
-
if (partial) {
|
|
94
|
-
const { when } = yield import("@microsoft/fast-element");
|
|
95
|
-
externalValues.push(when(x => pathResolver(behaviorConfig.value, self)(x), () => this.partials[partial]));
|
|
96
|
-
}
|
|
97
159
|
}
|
|
98
160
|
}
|
|
99
161
|
});
|
|
@@ -107,24 +169,31 @@ class TemplateElement extends FASTElement {
|
|
|
107
169
|
resolveAttributeDirective(name, propName, externalValues) {
|
|
108
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
171
|
switch (name) {
|
|
110
|
-
case "children":
|
|
111
|
-
|
|
112
|
-
const { children } = yield import("@microsoft/fast-element");
|
|
113
|
-
externalValues.push(children(propName));
|
|
114
|
-
}
|
|
172
|
+
case "children": {
|
|
173
|
+
externalValues.push(children(propName));
|
|
115
174
|
break;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
175
|
+
}
|
|
176
|
+
case "slotted": {
|
|
177
|
+
const parts = propName.trim().split(" filter ");
|
|
178
|
+
const slottedOption = {
|
|
179
|
+
property: parts[0],
|
|
180
|
+
};
|
|
181
|
+
if (parts[1]) {
|
|
182
|
+
if (parts[1].startsWith("elements(")) {
|
|
183
|
+
let params = parts[1].replace("elements(", "");
|
|
184
|
+
params = params.substring(0, params.lastIndexOf(")"));
|
|
185
|
+
Object.assign(slottedOption, {
|
|
186
|
+
filter: elements(params || undefined),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
120
189
|
}
|
|
190
|
+
externalValues.push(slotted(slottedOption));
|
|
121
191
|
break;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
externalValues.push(ref(propName));
|
|
126
|
-
}
|
|
192
|
+
}
|
|
193
|
+
case "ref": {
|
|
194
|
+
externalValues.push(ref(propName));
|
|
127
195
|
break;
|
|
196
|
+
}
|
|
128
197
|
}
|
|
129
198
|
});
|
|
130
199
|
}
|
|
@@ -135,43 +204,60 @@ class TemplateElement extends FASTElement {
|
|
|
135
204
|
* @param values - The interpreted values.
|
|
136
205
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
137
206
|
* @param behaviorConfig - The binding behavior configuration object.
|
|
207
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
138
208
|
*/
|
|
139
|
-
resolveDataBinding(innerHTML, strings, values, self = false, behaviorConfig) {
|
|
209
|
+
resolveDataBinding(rootPropertyName, innerHTML, strings, values, self = false, behaviorConfig, parentContext, level, schema, observerMap) {
|
|
140
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
211
|
switch (behaviorConfig.subtype) {
|
|
142
|
-
case "content":
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
212
|
+
case "content": {
|
|
213
|
+
strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
|
|
214
|
+
const type = "access";
|
|
215
|
+
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
216
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
217
|
+
const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
218
|
+
const contentBinding = (x, c) => binding(x, c);
|
|
219
|
+
values.push(contentBinding);
|
|
220
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
150
221
|
break;
|
|
151
|
-
|
|
222
|
+
}
|
|
223
|
+
case "attribute": {
|
|
152
224
|
strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
|
|
153
225
|
if (behaviorConfig.aspect === "@") {
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
|
|
226
|
+
const bindingHTML = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
227
|
+
const openingParenthesis = bindingHTML.indexOf("(");
|
|
228
|
+
const closingParenthesis = bindingHTML.indexOf(")");
|
|
229
|
+
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex -
|
|
230
|
+
(closingParenthesis - openingParenthesis) -
|
|
231
|
+
1);
|
|
232
|
+
const type = "event";
|
|
233
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
234
|
+
const arg = bindingHTML.slice(openingParenthesis + 1, closingParenthesis);
|
|
235
|
+
const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
236
|
+
const attributeBinding = (x, c) => binding(x, c).bind(x)(...(arg === "e" ? [c.event] : []), ...(arg !== "e" && arg !== ""
|
|
237
|
+
? [
|
|
238
|
+
bindingResolver(strings.join(""), rootPropertyName, arg, parentContext, type, schema, parentContext, level)(x, c),
|
|
239
|
+
]
|
|
240
|
+
: []));
|
|
241
|
+
values.push(attributeBinding);
|
|
157
242
|
}
|
|
158
243
|
else {
|
|
159
244
|
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
160
|
-
const
|
|
161
|
-
|
|
245
|
+
const type = "access";
|
|
246
|
+
rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
|
|
247
|
+
const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
|
|
248
|
+
const attributeBinding = (x, c) => binding(x, c);
|
|
249
|
+
values.push(attributeBinding);
|
|
162
250
|
}
|
|
163
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self);
|
|
251
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
164
252
|
break;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
yield this.resolveAttributeDirective(behaviorConfig.name, propName, values);
|
|
172
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self);
|
|
173
|
-
}
|
|
253
|
+
}
|
|
254
|
+
case "attributeDirective": {
|
|
255
|
+
strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex - behaviorConfig.name.length - 4));
|
|
256
|
+
const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
|
|
257
|
+
yield this.resolveAttributeDirective(behaviorConfig.name, propName, values);
|
|
258
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
174
259
|
break;
|
|
260
|
+
}
|
|
175
261
|
}
|
|
176
262
|
});
|
|
177
263
|
}
|
|
@@ -181,8 +267,9 @@ class TemplateElement extends FASTElement {
|
|
|
181
267
|
* @param strings - The strings array.
|
|
182
268
|
* @param values - The interpreted values.
|
|
183
269
|
* @param self - Indicates that this should refer to itself instead of a property when creating bindings.
|
|
270
|
+
* @param observerMap - ObserverMap instance for caching binding paths (optional).
|
|
184
271
|
*/
|
|
185
|
-
resolveInnerHTML(innerHTML, strings, values, self = false) {
|
|
272
|
+
resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self = false, parentContext, level, schema, observerMap) {
|
|
186
273
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
274
|
const behaviorConfig = getNextBehavior(innerHTML);
|
|
188
275
|
if (behaviorConfig === null) {
|
|
@@ -190,32 +277,33 @@ class TemplateElement extends FASTElement {
|
|
|
190
277
|
}
|
|
191
278
|
else {
|
|
192
279
|
switch (behaviorConfig.type) {
|
|
193
|
-
case "dataBinding":
|
|
194
|
-
yield this.resolveDataBinding(innerHTML, strings, values, self, behaviorConfig);
|
|
280
|
+
case "dataBinding": {
|
|
281
|
+
yield this.resolveDataBinding(rootPropertyName, innerHTML, strings, values, self, behaviorConfig, parentContext, level, schema, observerMap);
|
|
195
282
|
break;
|
|
196
|
-
|
|
283
|
+
}
|
|
284
|
+
case "templateDirective": {
|
|
197
285
|
strings.push(innerHTML.slice(0, behaviorConfig.openingTagStartIndex));
|
|
198
|
-
yield this.resolveTemplateDirective(behaviorConfig, values, innerHTML, self);
|
|
199
|
-
yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self);
|
|
286
|
+
yield this.resolveTemplateDirective(rootPropertyName, behaviorConfig, values, innerHTML, self, parentContext, level, schema, observerMap);
|
|
287
|
+
yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
|
|
200
288
|
break;
|
|
289
|
+
}
|
|
201
290
|
}
|
|
202
291
|
}
|
|
203
292
|
});
|
|
204
293
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Resolve all partial templates
|
|
207
|
-
* @param unresolvedInnerHTML - The innerHTML.
|
|
208
|
-
*/
|
|
209
|
-
resolveAllPartials(unresolvedInnerHTML) {
|
|
210
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
const allPartials = Object.entries(getAllPartials(unresolvedInnerHTML));
|
|
212
|
-
for (let i = 0, partialLength = allPartials.length; i < partialLength; i++) {
|
|
213
|
-
const { strings, values } = yield this.resolveStringsAndValues(allPartials[i][1].innerHTML);
|
|
214
|
-
this.partials[allPartials[i][0]] = this.resolveTemplateOrBehavior(strings, values);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* A dictionary of custom element options
|
|
297
|
+
*/
|
|
298
|
+
TemplateElement.elementOptions = {};
|
|
299
|
+
/**
|
|
300
|
+
* Default element options
|
|
301
|
+
*/
|
|
302
|
+
TemplateElement.defaultElementOptions = {};
|
|
303
|
+
/**
|
|
304
|
+
* Lifecycle callbacks for hydration events
|
|
305
|
+
*/
|
|
306
|
+
TemplateElement.lifecycleCallbacks = {};
|
|
219
307
|
__decorate([
|
|
220
308
|
attr,
|
|
221
309
|
__metadata("design:type", String)
|