@microsoft/fast-element 2.9.0 → 2.9.2
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/CHANGELOG.json +31 -1
- package/CHANGELOG.md +18 -2
- package/dist/context/context.api.json +7 -7
- package/dist/di/di.api.json +12 -12
- package/dist/dts/binding/two-way.d.ts +1 -1
- package/dist/dts/components/attributes.d.ts +3 -3
- package/dist/dts/components/fast-definitions.d.ts +1 -1
- package/dist/dts/context.d.ts +7 -7
- package/dist/dts/di/di.d.ts +13 -13
- package/dist/dts/dom-policy.d.ts +5 -5
- package/dist/dts/dom.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +7 -7
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +2 -2
- package/dist/dts/state/state.d.ts +9 -9
- package/dist/dts/styles/css-binding-directive.d.ts +1 -1
- package/dist/dts/styles/css-directive.d.ts +1 -1
- package/dist/dts/styles/css.d.ts +2 -2
- package/dist/dts/styles/element-styles.d.ts +2 -2
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +1 -1
- package/dist/dts/templating/html-directive.d.ts +3 -3
- package/dist/dts/templating/node-observation.d.ts +1 -1
- package/dist/dts/templating/render.d.ts +6 -6
- package/dist/dts/templating/template.d.ts +2 -2
- package/dist/esm/components/element-controller.js +84 -84
- package/dist/esm/components/fast-definitions.js +15 -15
- package/dist/esm/di/di.js +12 -12
- package/dist/esm/hydration/target-builder.js +21 -7
- package/dist/esm/observation/arrays.js +12 -12
- package/dist/esm/styles/element-styles.js +9 -9
- package/dist/esm/templating/repeat.js +7 -7
- package/dist/esm/templating/view.js +9 -9
- package/dist/fast-element.api.json +26 -26
- package/dist/fast-element.d.ts +4 -4
- package/dist/fast-element.debug.js +162 -146
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +162 -146
- package/dist/fast-element.min.js +2 -2
- package/docs/di/api-report.api.md +4 -4
- package/karma.conf.cjs +13 -7
- package/package.json +3 -44
|
@@ -4,7 +4,7 @@ import type { ExpressionObserver } from "../observation/observable.js";
|
|
|
4
4
|
import { AddBehavior, CSSDirective } from "./css-directive.js";
|
|
5
5
|
import type { ComposableStyles } from "./element-styles.js";
|
|
6
6
|
import type { HostBehavior, HostController } from "./host.js";
|
|
7
|
-
|
|
7
|
+
type CSSBindingEntry = {
|
|
8
8
|
observer: ExpressionObserver;
|
|
9
9
|
controller: HostController;
|
|
10
10
|
};
|
|
@@ -5,7 +5,7 @@ import type { ComposableStyles } from "./element-styles.js";
|
|
|
5
5
|
* Used to add behaviors when constructing styles.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
|
|
9
9
|
/**
|
|
10
10
|
* Directive for use in {@link css}.
|
|
11
11
|
*
|
package/dist/dts/styles/css.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ComposableStyles, ElementStyles } from "./element-styles.js";
|
|
|
6
6
|
* Represents the types of values that can be interpolated into a template.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type CSSValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | ComposableStyles | CSSDirective;
|
|
10
10
|
/**
|
|
11
11
|
* Transforms a template literal string into styles.
|
|
12
12
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -16,7 +16,7 @@ export declare type CSSValue<TSource, TParent = any> = Expression<TSource, any,
|
|
|
16
16
|
* Use the .partial method to create partial CSS fragments.
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type CSSTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]) => ElementStyles) & {
|
|
20
20
|
/**
|
|
21
21
|
* Transforms a template literal string into partial CSS.
|
|
22
22
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -4,12 +4,12 @@ import type { HostBehavior } from "./host.js";
|
|
|
4
4
|
* Represents styles that can be composed into the ShadowDOM of a custom element.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type ComposableStyles = string | ElementStyles | CSSStyleSheet;
|
|
8
8
|
/**
|
|
9
9
|
* A type that instantiates a StyleStrategy.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type ConstructibleStyleStrategy = {
|
|
13
13
|
/**
|
|
14
14
|
* Creates an instance of the strategy.
|
|
15
15
|
* @param styles - The styles to initialize the strategy with.
|
|
@@ -25,7 +25,7 @@ export interface SubtreeDirectiveOptions<T = any> extends NodeBehaviorOptions<T>
|
|
|
25
25
|
* The options used to configure child/subtree node observation.
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
|
|
29
29
|
/**
|
|
30
30
|
* The runtime behavior for child node observation.
|
|
31
31
|
* @public
|
|
@@ -6,7 +6,7 @@ import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from
|
|
|
6
6
|
* by the html template function into a result that can instantiate views.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type CompilationStrategy = (
|
|
10
10
|
/**
|
|
11
11
|
* The preprocessed HTML string or template to compile.
|
|
12
12
|
*/
|
|
@@ -6,7 +6,7 @@ import type { ExpressionController } from "../observation/observable.js";
|
|
|
6
6
|
* The target nodes available to a behavior.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type ViewBehaviorTargets = {
|
|
10
10
|
[id: string]: Node;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
@@ -61,12 +61,12 @@ export interface ViewBehaviorFactory {
|
|
|
61
61
|
* Represents a ViewBehaviorFactory after the compilation process has completed.
|
|
62
62
|
* @public
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
64
|
+
export type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
|
|
65
65
|
/**
|
|
66
66
|
* Used to add behavior factories when constructing templates.
|
|
67
67
|
* @public
|
|
68
68
|
*/
|
|
69
|
-
export
|
|
69
|
+
export type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
|
|
70
70
|
/**
|
|
71
71
|
* Instructs the template engine to apply behavior to a node.
|
|
72
72
|
* @public
|
|
@@ -22,7 +22,7 @@ export interface NodeBehaviorOptions<T = any> {
|
|
|
22
22
|
*
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a function that can be used to filter a Node array, selecting only elements.
|
|
28
28
|
* @param selector - An optional selector to restrict the filter to.
|
|
@@ -95,7 +95,7 @@ export interface RenderInstruction {
|
|
|
95
95
|
* Render options that are common to all configurations.
|
|
96
96
|
* @public
|
|
97
97
|
*/
|
|
98
|
-
export
|
|
98
|
+
export type CommonRenderOptions = {
|
|
99
99
|
/**
|
|
100
100
|
* The type this instruction is associated with.
|
|
101
101
|
*/
|
|
@@ -109,7 +109,7 @@ export declare type CommonRenderOptions = {
|
|
|
109
109
|
* Render options used to specify a template.
|
|
110
110
|
* @public
|
|
111
111
|
*/
|
|
112
|
-
export
|
|
112
|
+
export type TemplateRenderOptions = CommonRenderOptions & {
|
|
113
113
|
/**
|
|
114
114
|
* The template to use when rendering.
|
|
115
115
|
*/
|
|
@@ -119,7 +119,7 @@ export declare type TemplateRenderOptions = CommonRenderOptions & {
|
|
|
119
119
|
* Render options that are common to all element render instructions.
|
|
120
120
|
* @public
|
|
121
121
|
*/
|
|
122
|
-
export
|
|
122
|
+
export type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
|
|
123
123
|
/**
|
|
124
124
|
* Attributes to use when creating the element template.
|
|
125
125
|
* @remarks
|
|
@@ -149,7 +149,7 @@ export declare type BaseElementRenderOptions<TSource = any, TParent = any> = Com
|
|
|
149
149
|
* Render options for directly creating an element with {@link RenderInstruction.createElementTemplate}
|
|
150
150
|
* @public
|
|
151
151
|
*/
|
|
152
|
-
export
|
|
152
|
+
export type ElementCreateOptions<TSource = any, TParent = any> = Omit<BaseElementRenderOptions, "type" | "name"> & {
|
|
153
153
|
/**
|
|
154
154
|
* Directives to use when creating the element template. These directives are applied directly to the specified tag.
|
|
155
155
|
*
|
|
@@ -162,7 +162,7 @@ export declare type ElementCreateOptions<TSource = any, TParent = any> = Omit<Ba
|
|
|
162
162
|
* Render options used to specify an element.
|
|
163
163
|
* @public
|
|
164
164
|
*/
|
|
165
|
-
export
|
|
165
|
+
export type ElementConstructorRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
166
166
|
/**
|
|
167
167
|
* The element to use when rendering.
|
|
168
168
|
*/
|
|
@@ -172,7 +172,7 @@ export declare type ElementConstructorRenderOptions<TSource = any, TParent = any
|
|
|
172
172
|
* Render options use to specify an element by tag name.
|
|
173
173
|
* @public
|
|
174
174
|
*/
|
|
175
|
-
export
|
|
175
|
+
export type TagNameRenderOptions<TSource = any, TParent = any> = BaseElementRenderOptions<TSource, TParent> & {
|
|
176
176
|
/**
|
|
177
177
|
* The tag name to use when rendering.
|
|
178
178
|
*/
|
|
@@ -65,7 +65,7 @@ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
|
|
|
65
65
|
* Represents the types of values that can be interpolated into a template.
|
|
66
66
|
* @public
|
|
67
67
|
*/
|
|
68
|
-
export
|
|
68
|
+
export type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
|
|
69
69
|
/**
|
|
70
70
|
* Inlines a template into another template.
|
|
71
71
|
* @public
|
|
@@ -165,7 +165,7 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
165
165
|
* other template instances, and Directive instances.
|
|
166
166
|
* @public
|
|
167
167
|
*/
|
|
168
|
-
export
|
|
168
|
+
export type HTMLTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]) => ViewTemplate<TSource, TParent>) & {
|
|
169
169
|
/**
|
|
170
170
|
* Transforms a template literal string into partial HTML.
|
|
171
171
|
* @param html - The HTML string fragment to interpolate.
|
|
@@ -27,90 +27,6 @@ let elementControllerStrategy;
|
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
29
|
export class ElementController extends PropertyChangeNotifier {
|
|
30
|
-
/**
|
|
31
|
-
* Creates a Controller to control the specified element.
|
|
32
|
-
* @param element - The element to be controlled by this controller.
|
|
33
|
-
* @param definition - The element definition metadata that instructs this
|
|
34
|
-
* controller in how to handle rendering and other platform integrations.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
constructor(element, definition) {
|
|
38
|
-
super(element);
|
|
39
|
-
/**
|
|
40
|
-
* A map of observable properties that were set on the element before upgrade.
|
|
41
|
-
*/
|
|
42
|
-
this.boundObservables = null;
|
|
43
|
-
/**
|
|
44
|
-
* Indicates whether the controller needs to perform initial rendering.
|
|
45
|
-
*/
|
|
46
|
-
this.needsInitialization = true;
|
|
47
|
-
/**
|
|
48
|
-
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
49
|
-
*/
|
|
50
|
-
this.hasExistingShadowRoot = false;
|
|
51
|
-
/**
|
|
52
|
-
* The template used to render the component.
|
|
53
|
-
*/
|
|
54
|
-
this._template = null;
|
|
55
|
-
/**
|
|
56
|
-
* The current lifecycle stage of the controller.
|
|
57
|
-
*/
|
|
58
|
-
this.stage = 3 /* Stages.disconnected */;
|
|
59
|
-
/**
|
|
60
|
-
* A guard against connecting behaviors multiple times
|
|
61
|
-
* during connect in scenarios where a behavior adds
|
|
62
|
-
* another behavior during it's connectedCallback
|
|
63
|
-
*/
|
|
64
|
-
this.guardBehaviorConnection = false;
|
|
65
|
-
/**
|
|
66
|
-
* The behaviors associated with the component.
|
|
67
|
-
*/
|
|
68
|
-
this.behaviors = null;
|
|
69
|
-
/**
|
|
70
|
-
* Tracks whether behaviors are connected so that
|
|
71
|
-
* behaviors cant be connected multiple times
|
|
72
|
-
*/
|
|
73
|
-
this.behaviorsConnected = false;
|
|
74
|
-
/**
|
|
75
|
-
* The main set of styles used for the component, independent of any
|
|
76
|
-
* dynamically added styles.
|
|
77
|
-
*/
|
|
78
|
-
this._mainStyles = null;
|
|
79
|
-
/**
|
|
80
|
-
* This allows Observable.getNotifier(...) to return the Controller
|
|
81
|
-
* when the notifier for the Controller itself is being requested. The
|
|
82
|
-
* result is that the Observable system does not need to create a separate
|
|
83
|
-
* instance of Notifier for observables on the Controller. The component and
|
|
84
|
-
* the controller will now share the same notifier, removing one-object construct
|
|
85
|
-
* per web component instance.
|
|
86
|
-
*/
|
|
87
|
-
this.$fastController = this;
|
|
88
|
-
/**
|
|
89
|
-
* The view associated with the custom element.
|
|
90
|
-
* @remarks
|
|
91
|
-
* If `null` then the element is managing its own rendering.
|
|
92
|
-
*/
|
|
93
|
-
this.view = null;
|
|
94
|
-
this.source = element;
|
|
95
|
-
this.definition = definition;
|
|
96
|
-
this.shadowOptions = definition.shadowOptions;
|
|
97
|
-
// Capture any observable values that were set by the binding engine before
|
|
98
|
-
// the browser upgraded the element. Then delete the property since it will
|
|
99
|
-
// shadow the getter/setter that is required to make the observable operate.
|
|
100
|
-
// Later, in the connect callback, we'll re-apply the values.
|
|
101
|
-
const accessors = Observable.getAccessors(element);
|
|
102
|
-
if (accessors.length > 0) {
|
|
103
|
-
const boundObservables = (this.boundObservables = Object.create(null));
|
|
104
|
-
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
105
|
-
const propertyName = accessors[i].name;
|
|
106
|
-
const value = element[propertyName];
|
|
107
|
-
if (value !== void 0) {
|
|
108
|
-
delete element[propertyName];
|
|
109
|
-
boundObservables[propertyName] = value;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
30
|
/**
|
|
115
31
|
* Indicates whether or not the custom element has been
|
|
116
32
|
* connected to the document.
|
|
@@ -224,6 +140,90 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
224
140
|
this.addStyles(value);
|
|
225
141
|
}
|
|
226
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a Controller to control the specified element.
|
|
145
|
+
* @param element - The element to be controlled by this controller.
|
|
146
|
+
* @param definition - The element definition metadata that instructs this
|
|
147
|
+
* controller in how to handle rendering and other platform integrations.
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
constructor(element, definition) {
|
|
151
|
+
super(element);
|
|
152
|
+
/**
|
|
153
|
+
* A map of observable properties that were set on the element before upgrade.
|
|
154
|
+
*/
|
|
155
|
+
this.boundObservables = null;
|
|
156
|
+
/**
|
|
157
|
+
* Indicates whether the controller needs to perform initial rendering.
|
|
158
|
+
*/
|
|
159
|
+
this.needsInitialization = true;
|
|
160
|
+
/**
|
|
161
|
+
* Indicates whether the element has an existing shadow root (e.g. from declarative shadow DOM).
|
|
162
|
+
*/
|
|
163
|
+
this.hasExistingShadowRoot = false;
|
|
164
|
+
/**
|
|
165
|
+
* The template used to render the component.
|
|
166
|
+
*/
|
|
167
|
+
this._template = null;
|
|
168
|
+
/**
|
|
169
|
+
* The current lifecycle stage of the controller.
|
|
170
|
+
*/
|
|
171
|
+
this.stage = 3 /* Stages.disconnected */;
|
|
172
|
+
/**
|
|
173
|
+
* A guard against connecting behaviors multiple times
|
|
174
|
+
* during connect in scenarios where a behavior adds
|
|
175
|
+
* another behavior during it's connectedCallback
|
|
176
|
+
*/
|
|
177
|
+
this.guardBehaviorConnection = false;
|
|
178
|
+
/**
|
|
179
|
+
* The behaviors associated with the component.
|
|
180
|
+
*/
|
|
181
|
+
this.behaviors = null;
|
|
182
|
+
/**
|
|
183
|
+
* Tracks whether behaviors are connected so that
|
|
184
|
+
* behaviors cant be connected multiple times
|
|
185
|
+
*/
|
|
186
|
+
this.behaviorsConnected = false;
|
|
187
|
+
/**
|
|
188
|
+
* The main set of styles used for the component, independent of any
|
|
189
|
+
* dynamically added styles.
|
|
190
|
+
*/
|
|
191
|
+
this._mainStyles = null;
|
|
192
|
+
/**
|
|
193
|
+
* This allows Observable.getNotifier(...) to return the Controller
|
|
194
|
+
* when the notifier for the Controller itself is being requested. The
|
|
195
|
+
* result is that the Observable system does not need to create a separate
|
|
196
|
+
* instance of Notifier for observables on the Controller. The component and
|
|
197
|
+
* the controller will now share the same notifier, removing one-object construct
|
|
198
|
+
* per web component instance.
|
|
199
|
+
*/
|
|
200
|
+
this.$fastController = this;
|
|
201
|
+
/**
|
|
202
|
+
* The view associated with the custom element.
|
|
203
|
+
* @remarks
|
|
204
|
+
* If `null` then the element is managing its own rendering.
|
|
205
|
+
*/
|
|
206
|
+
this.view = null;
|
|
207
|
+
this.source = element;
|
|
208
|
+
this.definition = definition;
|
|
209
|
+
this.shadowOptions = definition.shadowOptions;
|
|
210
|
+
// Capture any observable values that were set by the binding engine before
|
|
211
|
+
// the browser upgraded the element. Then delete the property since it will
|
|
212
|
+
// shadow the getter/setter that is required to make the observable operate.
|
|
213
|
+
// Later, in the connect callback, we'll re-apply the values.
|
|
214
|
+
const accessors = Observable.getAccessors(element);
|
|
215
|
+
if (accessors.length > 0) {
|
|
216
|
+
const boundObservables = (this.boundObservables = Object.create(null));
|
|
217
|
+
for (let i = 0, ii = accessors.length; i < ii; ++i) {
|
|
218
|
+
const propertyName = accessors[i].name;
|
|
219
|
+
const value = element[propertyName];
|
|
220
|
+
if (value !== void 0) {
|
|
221
|
+
delete element[propertyName];
|
|
222
|
+
boundObservables[propertyName] = value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
227
|
/**
|
|
228
228
|
* Registers an unbind handler with the controller.
|
|
229
229
|
* @param behavior - An object to call when the controller unbinds.
|
|
@@ -33,6 +33,12 @@ export const TemplateOptions = {
|
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
35
|
export class FASTElementDefinition {
|
|
36
|
+
/**
|
|
37
|
+
* Indicates if this element has been defined in at least one registry.
|
|
38
|
+
*/
|
|
39
|
+
get isDefined() {
|
|
40
|
+
return this.platformDefined;
|
|
41
|
+
}
|
|
36
42
|
constructor(type, nameOrConfig = type.definition) {
|
|
37
43
|
var _b;
|
|
38
44
|
this.platformDefined = false;
|
|
@@ -75,14 +81,8 @@ export class FASTElementDefinition {
|
|
|
75
81
|
: Object.assign(Object.assign({}, defaultElementOptions), nameOrConfig.elementOptions);
|
|
76
82
|
this.styles = ElementStyles.normalize(nameOrConfig.styles);
|
|
77
83
|
fastElementRegistry.register(this);
|
|
78
|
-
Observable.defineProperty(
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Indicates if this element has been defined in at least one registry.
|
|
83
|
-
*/
|
|
84
|
-
get isDefined() {
|
|
85
|
-
return this.platformDefined;
|
|
84
|
+
Observable.defineProperty(_a.isRegistered, this.name);
|
|
85
|
+
_a.isRegistered[this.name] = this.type;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Defines a custom element based on this definition.
|
|
@@ -108,10 +108,10 @@ export class FASTElementDefinition {
|
|
|
108
108
|
*/
|
|
109
109
|
static compose(type, nameOrDef) {
|
|
110
110
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
111
|
-
return new
|
|
111
|
+
return new _a(class extends type {
|
|
112
112
|
}, nameOrDef);
|
|
113
113
|
}
|
|
114
|
-
return new
|
|
114
|
+
return new _a(type, nameOrDef);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Registers a FASTElement base type.
|
|
@@ -133,10 +133,10 @@ export class FASTElementDefinition {
|
|
|
133
133
|
static composeAsync(type, nameOrDef) {
|
|
134
134
|
return new Promise(resolve => {
|
|
135
135
|
if (fastElementBaseTypes.has(type) || fastElementRegistry.getByType(type)) {
|
|
136
|
-
resolve(new
|
|
136
|
+
resolve(new _a(class extends type {
|
|
137
137
|
}, nameOrDef));
|
|
138
138
|
}
|
|
139
|
-
const definition = new
|
|
139
|
+
const definition = new _a(type, nameOrDef);
|
|
140
140
|
Observable.getNotifier(definition).subscribe({
|
|
141
141
|
handleChange: () => {
|
|
142
142
|
var _b, _c;
|
|
@@ -169,10 +169,10 @@ FASTElementDefinition.getForInstance = fastElementRegistry.getForInstance;
|
|
|
169
169
|
*/
|
|
170
170
|
FASTElementDefinition.registerAsync = (name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
171
|
return new Promise(resolve => {
|
|
172
|
-
if (
|
|
173
|
-
resolve(
|
|
172
|
+
if (_a.isRegistered[name]) {
|
|
173
|
+
resolve(_a.isRegistered[name]);
|
|
174
174
|
}
|
|
175
|
-
Observable.getNotifier(
|
|
175
|
+
Observable.getNotifier(_a.isRegistered).subscribe({ handleChange: () => resolve(_a.isRegistered[name]) }, name);
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
Observable.defineProperty(FASTElementDefinition.prototype, "template");
|
package/dist/esm/di/di.js
CHANGED
|
@@ -902,6 +902,18 @@ const factories = new Map();
|
|
|
902
902
|
* @internal
|
|
903
903
|
*/
|
|
904
904
|
export class ContainerImpl {
|
|
905
|
+
get parent() {
|
|
906
|
+
if (this._parent === void 0) {
|
|
907
|
+
this._parent = this.config.parentLocator(this.owner);
|
|
908
|
+
}
|
|
909
|
+
return this._parent;
|
|
910
|
+
}
|
|
911
|
+
get depth() {
|
|
912
|
+
return this.parent === null ? 0 : this.parent.depth + 1;
|
|
913
|
+
}
|
|
914
|
+
get responsibleForOwnerRequests() {
|
|
915
|
+
return this.config.responsibleForOwnerRequests;
|
|
916
|
+
}
|
|
905
917
|
constructor(owner, config) {
|
|
906
918
|
this.owner = owner;
|
|
907
919
|
this.config = config;
|
|
@@ -935,18 +947,6 @@ export class ContainerImpl {
|
|
|
935
947
|
}
|
|
936
948
|
}
|
|
937
949
|
}
|
|
938
|
-
get parent() {
|
|
939
|
-
if (this._parent === void 0) {
|
|
940
|
-
this._parent = this.config.parentLocator(this.owner);
|
|
941
|
-
}
|
|
942
|
-
return this._parent;
|
|
943
|
-
}
|
|
944
|
-
get depth() {
|
|
945
|
-
return this.parent === null ? 0 : this.parent.depth + 1;
|
|
946
|
-
}
|
|
947
|
-
get responsibleForOwnerRequests() {
|
|
948
|
-
return this.config.responsibleForOwnerRequests;
|
|
949
|
-
}
|
|
950
950
|
handleContextRequests(enable) {
|
|
951
951
|
this.isHandlingContextRequests = enable;
|
|
952
952
|
}
|
|
@@ -52,6 +52,7 @@ function isShadowRoot(node) {
|
|
|
52
52
|
export function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
53
53
|
const range = createRangeForNodes(firstNode, lastNode);
|
|
54
54
|
const treeRoot = range.commonAncestorContainer;
|
|
55
|
+
const hydrationIndexOffset = getHydrationIndexOffset(factories);
|
|
55
56
|
const walker = document.createTreeWalker(treeRoot, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_COMMENT + NodeFilter.SHOW_TEXT, {
|
|
56
57
|
acceptNode(node) {
|
|
57
58
|
return range.comparePoint(node, 0) === 0
|
|
@@ -65,11 +66,11 @@ export function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
65
66
|
while (node !== null) {
|
|
66
67
|
switch (node.nodeType) {
|
|
67
68
|
case Node.ELEMENT_NODE: {
|
|
68
|
-
targetElement(node, factories, targets);
|
|
69
|
+
targetElement(node, factories, targets, hydrationIndexOffset);
|
|
69
70
|
break;
|
|
70
71
|
}
|
|
71
72
|
case Node.COMMENT_NODE: {
|
|
72
|
-
targetComment(node, walker, factories, targets, boundaries);
|
|
73
|
+
targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset);
|
|
73
74
|
break;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -78,21 +79,22 @@ export function buildViewBindingTargets(firstNode, lastNode, factories) {
|
|
|
78
79
|
range.detach();
|
|
79
80
|
return { targets, boundaries };
|
|
80
81
|
}
|
|
81
|
-
function targetElement(node, factories, targets) {
|
|
82
|
+
function targetElement(node, factories, targets, hydrationIndexOffset) {
|
|
82
83
|
var _a, _b;
|
|
83
84
|
// Check for attributes and map any factories.
|
|
84
85
|
const attrFactoryIds = (_b = (_a = HydrationMarkup.parseAttributeBinding(node)) !== null && _a !== void 0 ? _a : HydrationMarkup.parseEnumeratedAttributeBinding(node)) !== null && _b !== void 0 ? _b : HydrationMarkup.parseCompactAttributeBinding(node);
|
|
85
86
|
if (attrFactoryIds !== null) {
|
|
86
87
|
for (const id of attrFactoryIds) {
|
|
87
|
-
|
|
88
|
+
const factory = factories[id + hydrationIndexOffset];
|
|
89
|
+
if (!factory) {
|
|
88
90
|
throw new HydrationTargetElementError(`HydrationView was unable to successfully target factory on ${node.nodeName} inside ${node.getRootNode().host.nodeName}. This likely indicates a template mismatch between SSR rendering and hydration.`, factories, node);
|
|
89
91
|
}
|
|
90
|
-
targetFactory(
|
|
92
|
+
targetFactory(factory, node, targets);
|
|
91
93
|
}
|
|
92
94
|
node.removeAttribute(HydrationMarkup.attributeMarkerName);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
|
-
function targetComment(node, walker, factories, targets, boundaries) {
|
|
97
|
+
function targetComment(node, walker, factories, targets, boundaries, hydrationIndexOffset) {
|
|
96
98
|
if (HydrationMarkup.isElementBoundaryStartMarker(node)) {
|
|
97
99
|
skipToElementBoundaryEndMarker(node, walker);
|
|
98
100
|
return;
|
|
@@ -103,7 +105,7 @@ function targetComment(node, walker, factories, targets, boundaries) {
|
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
107
|
const [index, id] = parsed;
|
|
106
|
-
const factory = factories[index];
|
|
108
|
+
const factory = factories[index + hydrationIndexOffset];
|
|
107
109
|
const nodes = [];
|
|
108
110
|
let current = walker.nextSibling();
|
|
109
111
|
node.data = "";
|
|
@@ -167,6 +169,18 @@ function skipToElementBoundaryEndMarker(node, walker) {
|
|
|
167
169
|
current = walker.nextSibling();
|
|
168
170
|
}
|
|
169
171
|
}
|
|
172
|
+
function getHydrationIndexOffset(factories) {
|
|
173
|
+
let offset = 0;
|
|
174
|
+
for (let i = 0, ii = factories.length; i < ii; ++i) {
|
|
175
|
+
if (factories[i].targetNodeId === "h") {
|
|
176
|
+
offset++;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return offset;
|
|
183
|
+
}
|
|
170
184
|
export function targetFactory(factory, node, targets) {
|
|
171
185
|
if (factory.targetNodeId === undefined) {
|
|
172
186
|
// Dev error, this shouldn't ever be thrown
|
|
@@ -470,18 +470,6 @@ function setNonEnumerable(target, property, value, writable = true) {
|
|
|
470
470
|
});
|
|
471
471
|
}
|
|
472
472
|
class DefaultArrayObserver extends SubscriberSet {
|
|
473
|
-
constructor(subject) {
|
|
474
|
-
super(subject);
|
|
475
|
-
this.oldCollection = void 0;
|
|
476
|
-
this.splices = void 0;
|
|
477
|
-
this.sorts = void 0;
|
|
478
|
-
this.needsQueue = true;
|
|
479
|
-
this._strategy = null;
|
|
480
|
-
this._lengthObserver = void 0;
|
|
481
|
-
this._sortObserver = void 0;
|
|
482
|
-
this.call = this.flush;
|
|
483
|
-
setNonEnumerable(subject, "$fastController", this);
|
|
484
|
-
}
|
|
485
473
|
get strategy() {
|
|
486
474
|
return this._strategy;
|
|
487
475
|
}
|
|
@@ -522,6 +510,18 @@ class DefaultArrayObserver extends SubscriberSet {
|
|
|
522
510
|
}
|
|
523
511
|
return observer;
|
|
524
512
|
}
|
|
513
|
+
constructor(subject) {
|
|
514
|
+
super(subject);
|
|
515
|
+
this.oldCollection = void 0;
|
|
516
|
+
this.splices = void 0;
|
|
517
|
+
this.sorts = void 0;
|
|
518
|
+
this.needsQueue = true;
|
|
519
|
+
this._strategy = null;
|
|
520
|
+
this._lengthObserver = void 0;
|
|
521
|
+
this._sortObserver = void 0;
|
|
522
|
+
this.call = this.flush;
|
|
523
|
+
setNonEnumerable(subject, "$fastController", this);
|
|
524
|
+
}
|
|
525
525
|
subscribe(subscriber) {
|
|
526
526
|
this.flush();
|
|
527
527
|
super.subscribe(subscriber);
|
|
@@ -9,6 +9,15 @@ function reduceStyles(styles) {
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export class ElementStyles {
|
|
12
|
+
/**
|
|
13
|
+
* Gets the StyleStrategy associated with these element styles.
|
|
14
|
+
*/
|
|
15
|
+
get strategy() {
|
|
16
|
+
if (this._strategy === null) {
|
|
17
|
+
this.withStrategy(DefaultStyleStrategy);
|
|
18
|
+
}
|
|
19
|
+
return this._strategy;
|
|
20
|
+
}
|
|
12
21
|
/**
|
|
13
22
|
* Creates an instance of ElementStyles.
|
|
14
23
|
* @param styles - The styles that will be associated with elements.
|
|
@@ -21,15 +30,6 @@ export class ElementStyles {
|
|
|
21
30
|
.map((x) => x instanceof ElementStyles ? x.behaviors : null)
|
|
22
31
|
.reduce((prev, curr) => (curr === null ? prev : prev === null ? curr : prev.concat(curr)), null);
|
|
23
32
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Gets the StyleStrategy associated with these element styles.
|
|
26
|
-
*/
|
|
27
|
-
get strategy() {
|
|
28
|
-
if (this._strategy === null) {
|
|
29
|
-
this.withStrategy(DefaultStyleStrategy);
|
|
30
|
-
}
|
|
31
|
-
return this._strategy;
|
|
32
|
-
}
|
|
33
33
|
/** @internal */
|
|
34
34
|
addStylesTo(target) {
|
|
35
35
|
this.strategy.addStylesTo(target);
|
|
@@ -348,6 +348,13 @@ export class RepeatBehavior {
|
|
|
348
348
|
* @public
|
|
349
349
|
*/
|
|
350
350
|
export class RepeatDirective {
|
|
351
|
+
/**
|
|
352
|
+
* Creates a placeholder string based on the directive's index within the template.
|
|
353
|
+
* @param index - The index of the directive within the template.
|
|
354
|
+
*/
|
|
355
|
+
createHTML(add) {
|
|
356
|
+
return Markup.comment(add(this));
|
|
357
|
+
}
|
|
351
358
|
/**
|
|
352
359
|
* Creates an instance of RepeatDirective.
|
|
353
360
|
* @param dataBinding - The binding that provides the array to render.
|
|
@@ -360,13 +367,6 @@ export class RepeatDirective {
|
|
|
360
367
|
this.options = options;
|
|
361
368
|
ArrayObserver.enable();
|
|
362
369
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Creates a placeholder string based on the directive's index within the template.
|
|
365
|
-
* @param index - The index of the directive within the template.
|
|
366
|
-
*/
|
|
367
|
-
createHTML(add) {
|
|
368
|
-
return Markup.comment(add(this));
|
|
369
|
-
}
|
|
370
370
|
/**
|
|
371
371
|
* Creates a behavior for the provided target node.
|
|
372
372
|
* @param target - The node instance to create the behavior for.
|