@microsoft/fast-html 1.0.0-alpha.4 → 1.0.0-alpha.40

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.
Files changed (68) hide show
  1. package/README.md +242 -18
  2. package/dist/dts/components/element.d.ts +10 -0
  3. package/dist/dts/components/index.d.ts +3 -1
  4. package/dist/dts/components/observer-map.d.ts +27 -0
  5. package/dist/dts/components/schema.d.ts +144 -0
  6. package/dist/dts/components/template.d.ts +83 -7
  7. package/dist/dts/components/utilities.d.ts +126 -37
  8. package/dist/dts/index.d.ts +1 -1
  9. package/dist/dts/tsdoc-metadata.json +1 -1
  10. package/dist/esm/components/element.js +73 -0
  11. package/dist/esm/components/index.js +3 -1
  12. package/dist/esm/components/observer-map.js +68 -0
  13. package/dist/esm/components/observer-map.spec.js +39 -0
  14. package/dist/esm/components/schema.js +250 -0
  15. package/dist/esm/components/schema.spec.js +484 -0
  16. package/dist/esm/components/template.js +235 -213
  17. package/dist/esm/components/utilities.js +990 -64
  18. package/dist/esm/components/utilities.spec.js +522 -93
  19. package/dist/esm/index.js +1 -1
  20. package/dist/fast-html.api.json +350 -1
  21. package/dist/fast-html.d.ts +283 -6
  22. package/dist/fast-html.untrimmed.d.ts +283 -6
  23. package/package.json +27 -38
  24. package/rules/attribute-directives.yml +38 -0
  25. package/rules/call-expression-with-event-argument.yml +41 -0
  26. package/rules/member-expression.yml +33 -0
  27. package/rules/tag-function-to-template-literal.yml +16 -0
  28. package/dist/dts/fixtures/binding/binding.spec.d.ts +0 -1
  29. package/dist/dts/fixtures/binding/main.d.ts +0 -1
  30. package/dist/dts/fixtures/children/children.spec.d.ts +0 -1
  31. package/dist/dts/fixtures/children/main.d.ts +0 -1
  32. package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +0 -1
  33. package/dist/dts/fixtures/dot-syntax/main.d.ts +0 -1
  34. package/dist/dts/fixtures/event/event.spec.d.ts +0 -1
  35. package/dist/dts/fixtures/event/main.d.ts +0 -1
  36. package/dist/dts/fixtures/partial/main.d.ts +0 -1
  37. package/dist/dts/fixtures/partial/partial.spec.d.ts +0 -1
  38. package/dist/dts/fixtures/ref/main.d.ts +0 -1
  39. package/dist/dts/fixtures/ref/ref.spec.d.ts +0 -1
  40. package/dist/dts/fixtures/repeat/main.d.ts +0 -1
  41. package/dist/dts/fixtures/repeat/repeat.spec.d.ts +0 -1
  42. package/dist/dts/fixtures/slotted/main.d.ts +0 -1
  43. package/dist/dts/fixtures/slotted/slotted.spec.d.ts +0 -1
  44. package/dist/dts/fixtures/when/main.d.ts +0 -1
  45. package/dist/dts/fixtures/when/when.spec.d.ts +0 -1
  46. package/dist/esm/fixtures/attribute/attribute.spec.js +0 -23
  47. package/dist/esm/fixtures/attribute/main.js +0 -19
  48. package/dist/esm/fixtures/binding/binding.spec.js +0 -17
  49. package/dist/esm/fixtures/binding/main.js +0 -19
  50. package/dist/esm/fixtures/children/children.spec.js +0 -33
  51. package/dist/esm/fixtures/children/main.js +0 -24
  52. package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +0 -9
  53. package/dist/esm/fixtures/dot-syntax/main.js +0 -16
  54. package/dist/esm/fixtures/event/event.spec.js +0 -12
  55. package/dist/esm/fixtures/event/main.js +0 -16
  56. package/dist/esm/fixtures/partial/main.js +0 -31
  57. package/dist/esm/fixtures/partial/partial.spec.js +0 -14
  58. package/dist/esm/fixtures/ref/main.js +0 -14
  59. package/dist/esm/fixtures/ref/ref.spec.js +0 -13
  60. package/dist/esm/fixtures/repeat/main.js +0 -19
  61. package/dist/esm/fixtures/repeat/repeat.spec.js +0 -26
  62. package/dist/esm/fixtures/slotted/main.js +0 -22
  63. package/dist/esm/fixtures/slotted/slotted.spec.js +0 -25
  64. package/dist/esm/fixtures/when/main.js +0 -146
  65. package/dist/esm/fixtures/when/when.spec.js +0 -82
  66. package/dist/esm/tsconfig.tsbuildinfo +0 -1
  67. /package/dist/dts/{fixtures/attribute/attribute.spec.d.ts → components/observer-map.spec.d.ts} +0 -0
  68. /package/dist/dts/{fixtures/attribute/main.d.ts → components/schema.spec.d.ts} +0 -0
@@ -1,54 +1,124 @@
1
- import { __awaiter, __decorate, __metadata } from "tslib";
2
- import { attr, FAST, FASTElement, fastElementRegistry, ViewTemplate, } from "@microsoft/fast-element";
3
- import { DOMPolicy } from "@microsoft/fast-element/dom-policy.js";
4
- import { getAllPartials, getNextBehavior, getOperator, pathResolver, } from "./utilities.js";
1
+ import { __decorate, __metadata } from "tslib";
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({ ...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(...arguments);
11
- this.partials = {};
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
- if (this.name) {
16
- this.$fastController.definition.registry
17
- .whenDefined(this.name)
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(async (value) => {
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 } = await 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) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const strings = [];
44
- const values = []; // these can be bindings, directives, etc.
45
- yield this.resolveInnerHTML(innerHTML, strings, values, self);
46
- strings.raw = strings.map(value => String.raw({ raw: value }));
47
- return {
48
- strings,
49
- values,
50
- };
51
- });
113
+ async resolveStringsAndValues(rootPropertyName, innerHTML, self = false, parentContext, level, schema, observerMap) {
114
+ const strings = [];
115
+ const values = []; // these can be bindings, directives, etc.
116
+ await this.resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self, parentContext, level, schema, observerMap);
117
+ strings.raw = strings.map(value => String.raw({ raw: value }));
118
+ return {
119
+ strings,
120
+ values,
121
+ };
52
122
  }
53
123
  /**
54
124
  * Resolve a template or behavior
@@ -56,103 +126,35 @@ class TemplateElement extends FASTElement {
56
126
  * @param values - The interpreted values.
57
127
  */
58
128
  resolveTemplateOrBehavior(strings, values) {
59
- return ViewTemplate.create(strings, values, DOMPolicy.create());
129
+ return ViewTemplate.create(strings, values);
60
130
  }
61
131
  /**
62
132
  * Resolve a template directive
63
133
  * @param behaviorConfig - The directive behavior configuration object.
64
134
  * @param externalValues - The interpreted values from the parent.
65
135
  * @param innerHTML - The innerHTML.
136
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
137
+ * @param observerMap - ObserverMap instance for caching binding paths (optional).
66
138
  */
67
- resolveTemplateDirective(behaviorConfig, externalValues, innerHTML, self = false) {
68
- var _a;
69
- return __awaiter(this, void 0, void 0, function* () {
70
- switch (behaviorConfig.name) {
71
- case "when":
72
- {
73
- const { strings, values } = yield this.resolveStringsAndValues(innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex));
74
- const { when } = yield import("@microsoft/fast-element");
75
- const { operator, left, right, rightIsValue } = getOperator(behaviorConfig.value);
76
- let whenLogic = (x) => pathResolver(left, self)(x);
77
- switch (operator) {
78
- case "!":
79
- whenLogic = (x) => !pathResolver(left, self)(x);
80
- break;
81
- case "==":
82
- whenLogic = (x) => pathResolver(left, self)(x) ==
83
- (rightIsValue
84
- ? right
85
- : pathResolver(right, self)(x));
86
- break;
87
- case "!=":
88
- whenLogic = (x) => pathResolver(left, self)(x) !=
89
- (rightIsValue
90
- ? right
91
- : pathResolver(right, self)(x));
92
- break;
93
- case "&&":
94
- case "&amp;&amp;":
95
- whenLogic = (x) => pathResolver(left, self)(x) &&
96
- (rightIsValue
97
- ? right
98
- : pathResolver(right, self)(x));
99
- break;
100
- case "||":
101
- whenLogic = (x) => pathResolver(left, self)(x) ||
102
- (rightIsValue
103
- ? right
104
- : pathResolver(right, self)(x));
105
- break;
106
- case ">=":
107
- whenLogic = (x) => pathResolver(left, self)(x) >=
108
- (rightIsValue
109
- ? right
110
- : pathResolver(right, self)(x));
111
- break;
112
- case ">":
113
- whenLogic = (x) => pathResolver(left, self)(x) >
114
- (rightIsValue
115
- ? right
116
- : pathResolver(right, self)(x));
117
- break;
118
- case "<=":
119
- whenLogic = (x) => pathResolver(left, self)(x) <=
120
- (rightIsValue
121
- ? right
122
- : pathResolver(right, self)(x));
123
- break;
124
- case "<":
125
- whenLogic = (x) => pathResolver(left, self)(x) <
126
- (rightIsValue
127
- ? right
128
- : pathResolver(right, self)(x));
129
- break;
130
- }
131
- externalValues.push(when(whenLogic, this.resolveTemplateOrBehavior(strings, values)));
132
- }
133
- break;
134
- case "repeat":
135
- {
136
- const valueAttr = behaviorConfig.value.split(" "); // syntax {{x in y}}
137
- const { strings, values } = yield this.resolveStringsAndValues(innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true);
138
- const { repeat } = yield import("@microsoft/fast-element");
139
- externalValues.push(repeat(x => pathResolver(valueAttr[2], self)(x), this.resolveTemplateOrBehavior(strings, values)));
140
- }
141
- break;
142
- case "apply": {
143
- const openingTag = innerHTML.slice(behaviorConfig.openingTagStartIndex, behaviorConfig.openingTagEndIndex);
144
- const partial = (_a = openingTag
145
- .split(" ")
146
- .find(tagPart => {
147
- return tagPart.startsWith("partial");
148
- })) === null || _a === void 0 ? void 0 : _a.split('"')[1];
149
- if (partial) {
150
- const { when } = yield import("@microsoft/fast-element");
151
- externalValues.push(when(x => pathResolver(behaviorConfig.value, self)(x), () => this.partials[partial]));
152
- }
153
- }
139
+ async resolveTemplateDirective(rootPropertyName, behaviorConfig, externalValues, innerHTML, self = false, parentContext, level, schema, observerMap) {
140
+ switch (behaviorConfig.name) {
141
+ case "when": {
142
+ const expressionChain = getExpressionChain(behaviorConfig.value);
143
+ const whenLogic = resolveWhen(rootPropertyName, expressionChain, parentContext, level, schema);
144
+ const { strings, values } = await this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), self, parentContext, level, schema, observerMap);
145
+ externalValues.push(when(whenLogic, this.resolveTemplateOrBehavior(strings, values)));
146
+ break;
154
147
  }
155
- });
148
+ case "repeat": {
149
+ const valueAttr = behaviorConfig.value.split(" "); // syntax {{x in y}}
150
+ const updatedLevel = level + 1;
151
+ rootPropertyName = getRootPropertyName(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name);
152
+ const binding = bindingResolver(null, rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name, schema, valueAttr[0], level);
153
+ const { strings, values } = await this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true, valueAttr[0], updatedLevel, schema, observerMap);
154
+ externalValues.push(repeat((x, c) => binding(x, c), this.resolveTemplateOrBehavior(strings, values)));
155
+ break;
156
+ }
157
+ }
156
158
  }
157
159
  /**
158
160
  * Resolve a template directive
@@ -160,29 +162,34 @@ class TemplateElement extends FASTElement {
160
162
  * @param propName - The property name to pass to the directive.
161
163
  * @param externalValues - The interpreted values from the parent.
162
164
  */
163
- resolveAttributeDirective(name, propName, externalValues) {
164
- return __awaiter(this, void 0, void 0, function* () {
165
- switch (name) {
166
- case "children":
167
- {
168
- const { children } = yield import("@microsoft/fast-element");
169
- externalValues.push(children(propName));
170
- }
171
- break;
172
- case "slotted":
173
- {
174
- const { slotted } = yield import("@microsoft/fast-element");
175
- externalValues.push(slotted(propName));
176
- }
177
- break;
178
- case "ref":
179
- {
180
- const { ref } = yield import("@microsoft/fast-element");
181
- externalValues.push(ref(propName));
165
+ async resolveAttributeDirective(name, propName, externalValues) {
166
+ switch (name) {
167
+ case "children": {
168
+ externalValues.push(children(propName));
169
+ break;
170
+ }
171
+ case "slotted": {
172
+ const parts = propName.trim().split(" filter ");
173
+ const slottedOption = {
174
+ property: parts[0],
175
+ };
176
+ if (parts[1]) {
177
+ if (parts[1].startsWith("elements(")) {
178
+ let params = parts[1].replace("elements(", "");
179
+ params = params.substring(0, params.lastIndexOf(")"));
180
+ Object.assign(slottedOption, {
181
+ filter: elements(params || undefined),
182
+ });
182
183
  }
183
- break;
184
+ }
185
+ externalValues.push(slotted(slottedOption));
186
+ break;
184
187
  }
185
- });
188
+ case "ref": {
189
+ externalValues.push(ref(propName));
190
+ break;
191
+ }
192
+ }
186
193
  }
187
194
  /**
188
195
  * Resolver of a data binding
@@ -191,45 +198,60 @@ class TemplateElement extends FASTElement {
191
198
  * @param values - The interpreted values.
192
199
  * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
193
200
  * @param behaviorConfig - The binding behavior configuration object.
201
+ * @param observerMap - ObserverMap instance for caching binding paths (optional).
194
202
  */
195
- resolveDataBinding(innerHTML, strings, values, self = false, behaviorConfig) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- switch (behaviorConfig.subtype) {
198
- case "content":
199
- {
200
- strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
201
- const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
202
- const binding = (x) => pathResolver(propName, self)(x);
203
- values.push(binding);
204
- yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self);
205
- }
206
- break;
207
- case "attribute":
208
- strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
209
- if (behaviorConfig.aspect === "@") {
210
- const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex - 2);
211
- const binding = (x) => pathResolver(propName, self)(x)();
212
- values.push(binding);
213
- }
214
- else {
215
- const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
216
- const binding = (x) => pathResolver(propName, self)(x);
217
- values.push(binding);
218
- }
219
- yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self);
220
- break;
221
- case "attributeDirective":
222
- {
223
- strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex -
224
- behaviorConfig.name.length -
225
- 4));
226
- const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
227
- yield this.resolveAttributeDirective(behaviorConfig.name, propName, values);
228
- yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self);
229
- }
230
- break;
203
+ async resolveDataBinding(rootPropertyName, innerHTML, strings, values, self = false, behaviorConfig, parentContext, level, schema, observerMap) {
204
+ switch (behaviorConfig.subtype) {
205
+ case "content": {
206
+ strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
207
+ const type = "access";
208
+ const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
209
+ rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
210
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
211
+ const contentBinding = (x, c) => binding(x, c);
212
+ values.push(contentBinding);
213
+ await this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
214
+ break;
231
215
  }
232
- });
216
+ case "attribute": {
217
+ strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
218
+ if (behaviorConfig.aspect === "@") {
219
+ const bindingHTML = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
220
+ const openingParenthesis = bindingHTML.indexOf("(");
221
+ const closingParenthesis = bindingHTML.indexOf(")");
222
+ const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex -
223
+ (closingParenthesis - openingParenthesis) -
224
+ 1);
225
+ const type = "event";
226
+ rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
227
+ const arg = bindingHTML.slice(openingParenthesis + 1, closingParenthesis);
228
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
229
+ const attributeBinding = (x, c) => binding(x, c).bind(x)(...(arg === "e" ? [c.event] : []), ...(arg !== "e" && arg !== ""
230
+ ? [
231
+ bindingResolver(strings.join(""), rootPropertyName, arg, parentContext, type, schema, parentContext, level)(x, c),
232
+ ]
233
+ : []));
234
+ values.push(attributeBinding);
235
+ }
236
+ else {
237
+ const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
238
+ const type = "access";
239
+ rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
240
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
241
+ const attributeBinding = (x, c) => binding(x, c);
242
+ values.push(attributeBinding);
243
+ }
244
+ await this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
245
+ break;
246
+ }
247
+ case "attributeDirective": {
248
+ strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex - behaviorConfig.name.length - 4));
249
+ const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
250
+ await this.resolveAttributeDirective(behaviorConfig.name, propName, values);
251
+ await this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex + 1, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
252
+ break;
253
+ }
254
+ }
233
255
  }
234
256
  /**
235
257
  * Resolver of the innerHTML string
@@ -237,41 +259,41 @@ class TemplateElement extends FASTElement {
237
259
  * @param strings - The strings array.
238
260
  * @param values - The interpreted values.
239
261
  * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
262
+ * @param observerMap - ObserverMap instance for caching binding paths (optional).
240
263
  */
241
- resolveInnerHTML(innerHTML, strings, values, self = false) {
242
- return __awaiter(this, void 0, void 0, function* () {
243
- const behaviorConfig = getNextBehavior(innerHTML);
244
- if (behaviorConfig === null) {
245
- strings.push(innerHTML);
246
- }
247
- else {
248
- switch (behaviorConfig.type) {
249
- case "dataBinding":
250
- yield this.resolveDataBinding(innerHTML, strings, values, self, behaviorConfig);
251
- break;
252
- case "templateDirective":
253
- strings.push(innerHTML.slice(0, behaviorConfig.openingTagStartIndex));
254
- yield this.resolveTemplateDirective(behaviorConfig, values, innerHTML, self);
255
- yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self);
256
- break;
264
+ async resolveInnerHTML(rootPropertyName, innerHTML, strings, values, self = false, parentContext, level, schema, observerMap) {
265
+ const behaviorConfig = getNextBehavior(innerHTML);
266
+ if (behaviorConfig === null) {
267
+ strings.push(innerHTML);
268
+ }
269
+ else {
270
+ switch (behaviorConfig.type) {
271
+ case "dataBinding": {
272
+ await this.resolveDataBinding(rootPropertyName, innerHTML, strings, values, self, behaviorConfig, parentContext, level, schema, observerMap);
273
+ break;
274
+ }
275
+ case "templateDirective": {
276
+ strings.push(innerHTML.slice(0, behaviorConfig.openingTagStartIndex));
277
+ await this.resolveTemplateDirective(rootPropertyName, behaviorConfig, values, innerHTML, self, parentContext, level, schema, observerMap);
278
+ await this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingTagEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
279
+ break;
257
280
  }
258
281
  }
259
- });
260
- }
261
- /**
262
- * Resolve all partial templates
263
- * @param unresolvedInnerHTML - The innerHTML.
264
- */
265
- resolveAllPartials(unresolvedInnerHTML) {
266
- return __awaiter(this, void 0, void 0, function* () {
267
- const allPartials = Object.entries(getAllPartials(unresolvedInnerHTML));
268
- for (let i = 0, partialLength = allPartials.length; i < partialLength; i++) {
269
- const { strings, values } = yield this.resolveStringsAndValues(allPartials[i][1].innerHTML);
270
- this.partials[allPartials[i][0]] = this.resolveTemplateOrBehavior(strings, values);
271
- }
272
- });
282
+ }
273
283
  }
274
284
  }
285
+ /**
286
+ * A dictionary of custom element options
287
+ */
288
+ TemplateElement.elementOptions = {};
289
+ /**
290
+ * Default element options
291
+ */
292
+ TemplateElement.defaultElementOptions = {};
293
+ /**
294
+ * Lifecycle callbacks for hydration events
295
+ */
296
+ TemplateElement.lifecycleCallbacks = {};
275
297
  __decorate([
276
298
  attr,
277
299
  __metadata("design:type", String)