@microsoft/fast-element 2.0.0-beta.15 → 2.0.0-beta.17
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 +30 -0
- package/CHANGELOG.md +17 -1
- package/dist/dts/components/element-controller.d.ts +12 -2
- package/dist/dts/templating/html-directive.d.ts +6 -1
- package/dist/dts/templating/node-observation.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +5 -0
- package/dist/dts/templating/view.d.ts +6 -1
- package/dist/dts/testing/fakes.d.ts +1 -0
- package/dist/esm/components/element-controller.js +29 -14
- package/dist/esm/observation/observable.js +5 -1
- package/dist/esm/templating/binding-signal.js +6 -1
- package/dist/esm/templating/binding-two-way.js +6 -1
- package/dist/esm/templating/binding.js +9 -1
- package/dist/esm/templating/children.js +8 -4
- package/dist/esm/templating/html-directive.js +6 -0
- package/dist/esm/templating/node-observation.js +4 -4
- package/dist/esm/templating/template.js +6 -1
- package/dist/esm/templating/view.js +6 -0
- package/dist/esm/testing/fakes.js +2 -0
- package/dist/fast-element.d.ts +12 -3
- package/dist/fast-element.debug.js +70 -20
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +70 -20
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +28 -3
- package/docs/api-report.md +8 -0
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-element",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Tue, 01 Nov 2022 23:26:26 GMT",
|
|
6
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.17",
|
|
7
|
+
"version": "2.0.0-beta.17",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "roeisenb@microsoft.com",
|
|
12
|
+
"package": "@microsoft/fast-element",
|
|
13
|
+
"commit": "a4982f452702a8fee67397767b603d4a67702b10",
|
|
14
|
+
"comment": "fix: prevent circular reference errors when stringifying DOM nodes controlled by FAST's rendering engine"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 28 Oct 2022 20:44:44 GMT",
|
|
21
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.16",
|
|
22
|
+
"version": "2.0.0-beta.16",
|
|
23
|
+
"comments": {
|
|
24
|
+
"prerelease": [
|
|
25
|
+
{
|
|
26
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
27
|
+
"package": "@microsoft/fast-element",
|
|
28
|
+
"commit": "5b745b1fb3bf249a7a2d172b7fb69cb08694aadd",
|
|
29
|
+
"comment": "Fixed bug preventing main component stylesheet behaviors from being connected during connectedCallback"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
4
34
|
{
|
|
5
35
|
"date": "Tue, 25 Oct 2022 20:24:32 GMT",
|
|
6
36
|
"tag": "@microsoft/fast-element_v2.0.0-beta.15",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# Change Log - @microsoft/fast-element
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 01 Nov 2022 23:26:26 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.0.0-beta.17
|
|
8
|
+
|
|
9
|
+
Tue, 01 Nov 2022 23:26:26 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- fix: prevent circular reference errors when stringifying DOM nodes controlled by FAST's rendering engine (roeisenb@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 2.0.0-beta.16
|
|
16
|
+
|
|
17
|
+
Fri, 28 Oct 2022 20:44:44 GMT
|
|
18
|
+
|
|
19
|
+
### Changes
|
|
20
|
+
|
|
21
|
+
- Fixed bug preventing main component stylesheet behaviors from being connected during connectedCallback (nicholasrice@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 2.0.0-beta.15
|
|
8
24
|
|
|
9
25
|
Tue, 25 Oct 2022 20:24:32 GMT
|
|
@@ -21,7 +21,13 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
21
21
|
private needsInitialization;
|
|
22
22
|
private hasExistingShadowRoot;
|
|
23
23
|
private _template;
|
|
24
|
-
private
|
|
24
|
+
private stage;
|
|
25
|
+
/**
|
|
26
|
+
* A guard against connecting behaviors multiple times
|
|
27
|
+
* during connect in scenarios where a behavior adds
|
|
28
|
+
* another behavior during it's connectedCallback
|
|
29
|
+
*/
|
|
30
|
+
private guardBehaviorConnection;
|
|
25
31
|
private behaviors;
|
|
26
32
|
private _mainStyles;
|
|
27
33
|
/**
|
|
@@ -53,7 +59,6 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
53
59
|
* connected to the document.
|
|
54
60
|
*/
|
|
55
61
|
get isConnected(): boolean;
|
|
56
|
-
private setIsConnected;
|
|
57
62
|
/**
|
|
58
63
|
* Gets/sets the template used to render the component.
|
|
59
64
|
* @remarks
|
|
@@ -120,6 +125,11 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
120
125
|
* Only emits events if connected.
|
|
121
126
|
*/
|
|
122
127
|
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Opts out of JSON stringification.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
toJSON: () => undefined;
|
|
123
133
|
private renderTemplate;
|
|
124
134
|
/**
|
|
125
135
|
* Locates or creates a controller for the specified element.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HostBehavior } from "../index.js";
|
|
2
|
-
import
|
|
2
|
+
import { Constructable } from "../interfaces.js";
|
|
3
3
|
import type { Subscriber } from "../observation/notifier.js";
|
|
4
4
|
import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
|
|
5
5
|
/**
|
|
@@ -259,6 +259,11 @@ export declare abstract class StatelessAttachedAttributeDirective<TOptions> impl
|
|
|
259
259
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
260
260
|
*/
|
|
261
261
|
nodeId: string;
|
|
262
|
+
/**
|
|
263
|
+
* Opts out of JSON stringification.
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
toJSON: () => undefined;
|
|
262
267
|
/**
|
|
263
268
|
* Creates an instance of RefDirective.
|
|
264
269
|
* @param options - The options to use in configuring the directive.
|
|
@@ -36,7 +36,7 @@ export declare const elements: (selector?: string) => ElementsFilter;
|
|
|
36
36
|
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
37
37
|
*/
|
|
38
38
|
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
39
|
-
private
|
|
39
|
+
private controllerProperty;
|
|
40
40
|
/**
|
|
41
41
|
* Bind this behavior to the source.
|
|
42
42
|
* @param source - The source to bind to.
|
|
@@ -75,6 +75,11 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
75
75
|
* host that the template is being attached to.
|
|
76
76
|
*/
|
|
77
77
|
render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
78
|
+
/**
|
|
79
|
+
* Opts out of JSON stringification.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
toJSON: () => undefined;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* A marker interface used to capture types when interpolating Directive helpers
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Disposable } from "../interfaces.js";
|
|
2
2
|
import { ExecutionContext, SourceLifetime } from "../observation/observable.js";
|
|
3
3
|
import type { ViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
|
|
4
4
|
/**
|
|
@@ -185,6 +185,11 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
|
|
|
185
185
|
* Unbinds a view's behaviors from its binding source.
|
|
186
186
|
*/
|
|
187
187
|
unbind(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Opts out of JSON stringification.
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
toJSON: () => undefined;
|
|
188
193
|
private evaluateUnbindables;
|
|
189
194
|
/**
|
|
190
195
|
* Efficiently disposes of a contiguous range of synthetic view instances.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../interfaces.js";
|
|
1
|
+
import { noop } from "../interfaces.js";
|
|
2
2
|
import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
3
3
|
import { Observable, SourceLifetime } from "../observation/observable.js";
|
|
4
4
|
import { FAST } from "../platform.js";
|
|
@@ -34,7 +34,13 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
34
34
|
this.needsInitialization = true;
|
|
35
35
|
this.hasExistingShadowRoot = false;
|
|
36
36
|
this._template = null;
|
|
37
|
-
this.
|
|
37
|
+
this.stage = 3 /* Stages.disconnected */;
|
|
38
|
+
/**
|
|
39
|
+
* A guard against connecting behaviors multiple times
|
|
40
|
+
* during connect in scenarios where a behavior adds
|
|
41
|
+
* another behavior during it's connectedCallback
|
|
42
|
+
*/
|
|
43
|
+
this.guardBehaviorConnection = false;
|
|
38
44
|
this.behaviors = null;
|
|
39
45
|
this._mainStyles = null;
|
|
40
46
|
/**
|
|
@@ -52,6 +58,11 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
52
58
|
* If `null` then the element is managing its own rendering.
|
|
53
59
|
*/
|
|
54
60
|
this.view = null;
|
|
61
|
+
/**
|
|
62
|
+
* Opts out of JSON stringification.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
this.toJSON = noop;
|
|
55
66
|
this.source = element;
|
|
56
67
|
this.definition = definition;
|
|
57
68
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -90,11 +101,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
90
101
|
*/
|
|
91
102
|
get isConnected() {
|
|
92
103
|
Observable.track(this, isConnectedPropertyName);
|
|
93
|
-
return this.
|
|
94
|
-
}
|
|
95
|
-
setIsConnected(value) {
|
|
96
|
-
this._isConnected = value;
|
|
97
|
-
Observable.notify(this, isConnectedPropertyName);
|
|
104
|
+
return this.stage === 1 /* Stages.connected */;
|
|
98
105
|
}
|
|
99
106
|
/**
|
|
100
107
|
* Gets/sets the template used to render the component.
|
|
@@ -169,7 +176,9 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
169
176
|
if (count === 0) {
|
|
170
177
|
targetBehaviors.set(behavior, 1);
|
|
171
178
|
behavior.addedCallback && behavior.addedCallback(this);
|
|
172
|
-
if (behavior.connectedCallback &&
|
|
179
|
+
if (behavior.connectedCallback &&
|
|
180
|
+
!this.guardBehaviorConnection &&
|
|
181
|
+
(this.stage === 1 /* Stages.connected */ || this.stage === 0 /* Stages.connecting */)) {
|
|
173
182
|
behavior.connectedCallback(this);
|
|
174
183
|
}
|
|
175
184
|
}
|
|
@@ -193,7 +202,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
193
202
|
}
|
|
194
203
|
if (count === 1 || force) {
|
|
195
204
|
targetBehaviors.delete(behavior);
|
|
196
|
-
if (behavior.disconnectedCallback && this.
|
|
205
|
+
if (behavior.disconnectedCallback && this.stage !== 3 /* Stages.disconnected */) {
|
|
197
206
|
behavior.disconnectedCallback(this);
|
|
198
207
|
}
|
|
199
208
|
behavior.removedCallback && behavior.removedCallback(this);
|
|
@@ -254,9 +263,10 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
254
263
|
* Runs connected lifecycle behavior on the associated element.
|
|
255
264
|
*/
|
|
256
265
|
connect() {
|
|
257
|
-
if (this.
|
|
266
|
+
if (this.stage !== 3 /* Stages.disconnected */) {
|
|
258
267
|
return;
|
|
259
268
|
}
|
|
269
|
+
this.stage = 0 /* Stages.connecting */;
|
|
260
270
|
// If we have any observables that were bound, re-apply their values.
|
|
261
271
|
if (this.boundObservables !== null) {
|
|
262
272
|
const element = this.source;
|
|
@@ -270,9 +280,11 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
270
280
|
}
|
|
271
281
|
const behaviors = this.behaviors;
|
|
272
282
|
if (behaviors !== null) {
|
|
283
|
+
this.guardBehaviorConnection = true;
|
|
273
284
|
for (const key of behaviors.keys()) {
|
|
274
285
|
key.connectedCallback && key.connectedCallback(this);
|
|
275
286
|
}
|
|
287
|
+
this.guardBehaviorConnection = false;
|
|
276
288
|
}
|
|
277
289
|
if (this.needsInitialization) {
|
|
278
290
|
this.renderTemplate(this.template);
|
|
@@ -282,16 +294,18 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
282
294
|
else if (this.view !== null) {
|
|
283
295
|
this.view.bind(this.source);
|
|
284
296
|
}
|
|
285
|
-
this.
|
|
297
|
+
this.stage = 1 /* Stages.connected */;
|
|
298
|
+
Observable.notify(this, isConnectedPropertyName);
|
|
286
299
|
}
|
|
287
300
|
/**
|
|
288
301
|
* Runs disconnected lifecycle behavior on the associated element.
|
|
289
302
|
*/
|
|
290
303
|
disconnect() {
|
|
291
|
-
if (
|
|
304
|
+
if (this.stage !== 1 /* Stages.connected */) {
|
|
292
305
|
return;
|
|
293
306
|
}
|
|
294
|
-
this.
|
|
307
|
+
this.stage = 2 /* Stages.disconnecting */;
|
|
308
|
+
Observable.notify(this, isConnectedPropertyName);
|
|
295
309
|
if (this.view !== null) {
|
|
296
310
|
this.view.unbind();
|
|
297
311
|
}
|
|
@@ -301,6 +315,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
301
315
|
key.disconnectedCallback && key.disconnectedCallback(this);
|
|
302
316
|
}
|
|
303
317
|
}
|
|
318
|
+
this.stage = 3 /* Stages.disconnected */;
|
|
304
319
|
}
|
|
305
320
|
/**
|
|
306
321
|
* Runs the attribute changed callback for the associated element.
|
|
@@ -323,7 +338,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
323
338
|
* Only emits events if connected.
|
|
324
339
|
*/
|
|
325
340
|
emit(type, detail, options) {
|
|
326
|
-
if (this.
|
|
341
|
+
if (this.stage === 1 /* Stages.connected */) {
|
|
327
342
|
return this.source.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign({ detail }, defaultEventOptions), options)));
|
|
328
343
|
}
|
|
329
344
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, isString, } from "../interfaces.js";
|
|
1
|
+
import { isFunction, isString, noop, } from "../interfaces.js";
|
|
2
2
|
import { createMetadataLocator, FAST } from "../platform.js";
|
|
3
3
|
import { Updates } from "./update-queue.js";
|
|
4
4
|
import { PropertyChangeNotifier, SubscriberSet } from "./notifier.js";
|
|
@@ -79,6 +79,10 @@ export const Observable = FAST.getById(2 /* KernelServiceId.observable */, () =>
|
|
|
79
79
|
this.propertyName = void 0;
|
|
80
80
|
this.notifier = void 0;
|
|
81
81
|
this.next = void 0;
|
|
82
|
+
/**
|
|
83
|
+
* Opts out of JSON stringification.
|
|
84
|
+
*/
|
|
85
|
+
this.toJSON = noop;
|
|
82
86
|
}
|
|
83
87
|
setMode(isAsync) {
|
|
84
88
|
this.isAsync = this.needsQueue = isAsync;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isString } from "../interfaces.js";
|
|
1
|
+
import { isString, noop } from "../interfaces.js";
|
|
2
2
|
import { Binding } from "./html-directive.js";
|
|
3
3
|
const subscribers = Object.create(null);
|
|
4
4
|
export const Signal = Object.freeze({
|
|
@@ -41,6 +41,11 @@ class SignalObserver {
|
|
|
41
41
|
this.dataBinding = dataBinding;
|
|
42
42
|
this.subscriber = subscriber;
|
|
43
43
|
this.isNotBound = true;
|
|
44
|
+
/**
|
|
45
|
+
* Opts out of JSON stringification.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
this.toJSON = noop;
|
|
44
49
|
}
|
|
45
50
|
bind(controller) {
|
|
46
51
|
if (this.isNotBound) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isString } from "../interfaces.js";
|
|
1
|
+
import { isString, noop } from "../interfaces.js";
|
|
2
2
|
import { Observable, } from "../observation/observable.js";
|
|
3
3
|
import { FAST } from "../platform.js";
|
|
4
4
|
import { Binding } from "./html-directive.js";
|
|
@@ -25,6 +25,11 @@ class TwoWayObserver {
|
|
|
25
25
|
this.subscriber = subscriber;
|
|
26
26
|
this.dataBinding = dataBinding;
|
|
27
27
|
this.isNotBound = true;
|
|
28
|
+
/**
|
|
29
|
+
* Opts out of JSON stringification.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
this.toJSON = noop;
|
|
28
33
|
this.notifier = Observable.binding(dataBinding.evaluate, this, dataBinding.isVolatile);
|
|
29
34
|
}
|
|
30
35
|
bind(controller) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction } from "../interfaces.js";
|
|
1
|
+
import { isFunction, noop } from "../interfaces.js";
|
|
2
2
|
import { ExecutionContext, Observable, } from "../observation/observable.js";
|
|
3
3
|
import { FAST } from "../platform.js";
|
|
4
4
|
import { DOM } from "./dom.js";
|
|
@@ -19,6 +19,14 @@ class OnChangeBinding extends Binding {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
class OneTimeBinding extends Binding {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
/**
|
|
25
|
+
* Opts out of JSON stringification.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
this.toJSON = noop;
|
|
29
|
+
}
|
|
22
30
|
createObserver() {
|
|
23
31
|
return this;
|
|
24
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isString } from "../interfaces.js";
|
|
1
|
+
import { isString, noop } from "../interfaces.js";
|
|
2
2
|
import { HTMLDirective } from "./html-directive.js";
|
|
3
3
|
import { NodeObservationDirective } from "./node-observation.js";
|
|
4
4
|
/**
|
|
@@ -24,9 +24,13 @@ export class ChildrenDirective extends NodeObservationDirective {
|
|
|
24
24
|
* @param target - The target to observe.
|
|
25
25
|
*/
|
|
26
26
|
observe(target) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
let observer = target[this.observerProperty];
|
|
28
|
+
if (!observer) {
|
|
29
|
+
observer = new MutationObserver(this.handleEvent);
|
|
30
|
+
observer.toJSON = noop;
|
|
31
|
+
observer.target = target;
|
|
32
|
+
target[this.observerProperty] = observer;
|
|
33
|
+
}
|
|
30
34
|
observer.observe(target, this.options);
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noop } from "../interfaces.js";
|
|
1
2
|
import { ExecutionContext, } from "../observation/observable.js";
|
|
2
3
|
import { createTypeRegistry } from "../platform.js";
|
|
3
4
|
import { Markup, nextId } from "./markup.js";
|
|
@@ -201,6 +202,11 @@ export class StatelessAttachedAttributeDirective {
|
|
|
201
202
|
* The unique id of the factory.
|
|
202
203
|
*/
|
|
203
204
|
this.id = nextId();
|
|
205
|
+
/**
|
|
206
|
+
* Opts out of JSON stringification.
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
this.toJSON = noop;
|
|
204
210
|
}
|
|
205
211
|
/**
|
|
206
212
|
* Creates a placeholder string based on the directive's index within the template.
|
|
@@ -18,7 +18,7 @@ export const elements = (selector) => selector
|
|
|
18
18
|
export class NodeObservationDirective extends StatelessAttachedAttributeDirective {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
|
-
this.
|
|
21
|
+
this.controllerProperty = `${this.id}-c`;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Bind this behavior to the source.
|
|
@@ -28,7 +28,7 @@ export class NodeObservationDirective extends StatelessAttachedAttributeDirectiv
|
|
|
28
28
|
*/
|
|
29
29
|
bind(controller) {
|
|
30
30
|
const target = controller.targets[this.nodeId];
|
|
31
|
-
target[this.
|
|
31
|
+
target[this.controllerProperty] = controller;
|
|
32
32
|
this.updateTarget(controller.source, this.computeNodes(target));
|
|
33
33
|
this.observe(target);
|
|
34
34
|
controller.onUnbind(this);
|
|
@@ -43,7 +43,7 @@ export class NodeObservationDirective extends StatelessAttachedAttributeDirectiv
|
|
|
43
43
|
const target = controller.targets[this.nodeId];
|
|
44
44
|
this.updateTarget(controller.source, emptyArray);
|
|
45
45
|
this.disconnect(target);
|
|
46
|
-
target[this.
|
|
46
|
+
target[this.controllerProperty] = null;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Gets the data source for the target.
|
|
@@ -51,7 +51,7 @@ export class NodeObservationDirective extends StatelessAttachedAttributeDirectiv
|
|
|
51
51
|
* @returns The source.
|
|
52
52
|
*/
|
|
53
53
|
getSource(target) {
|
|
54
|
-
return target[this.
|
|
54
|
+
return target[this.controllerProperty].source;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Updates the source property with the computed nodes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFunction, isString } from "../interfaces.js";
|
|
1
|
+
import { isFunction, isString, noop } from "../interfaces.js";
|
|
2
2
|
import { bind, HTMLBindingDirective, oneTime } from "./binding.js";
|
|
3
3
|
import { Compiler } from "./compiler.js";
|
|
4
4
|
import { Aspect, Binding, HTMLDirective, } from "./html-directive.js";
|
|
@@ -15,6 +15,11 @@ export class ViewTemplate {
|
|
|
15
15
|
*/
|
|
16
16
|
constructor(html, factories) {
|
|
17
17
|
this.result = null;
|
|
18
|
+
/**
|
|
19
|
+
* Opts out of JSON stringification.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
this.toJSON = noop;
|
|
18
23
|
this.html = html;
|
|
19
24
|
this.factories = factories;
|
|
20
25
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noop } from "../interfaces.js";
|
|
1
2
|
import { ExecutionContext, Observable, SourceLifetime, } from "../observation/observable.js";
|
|
2
3
|
function removeNodeSequence(firstNode, lastNode) {
|
|
3
4
|
const parent = firstNode.parentNode;
|
|
@@ -50,6 +51,11 @@ export class HTMLView {
|
|
|
50
51
|
* The length of the current collection within a repeat context.
|
|
51
52
|
*/
|
|
52
53
|
this.length = 0;
|
|
54
|
+
/**
|
|
55
|
+
* Opts out of JSON stringification.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
this.toJSON = noop;
|
|
53
59
|
this.firstChild = fragment.firstChild;
|
|
54
60
|
this.lastChild = fragment.lastChild;
|
|
55
61
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext, } from "../index.js";
|
|
2
|
+
import { noop } from "../interfaces.js";
|
|
2
3
|
export const Fake = Object.freeze({
|
|
3
4
|
executionContext(parent, parentContext) {
|
|
4
5
|
return {
|
|
@@ -83,6 +84,7 @@ export const Fake = Object.freeze({
|
|
|
83
84
|
},
|
|
84
85
|
source: null,
|
|
85
86
|
targets,
|
|
87
|
+
toJSON: noop,
|
|
86
88
|
bind(source, context = Fake.executionContext()) {
|
|
87
89
|
if (this.isBound) {
|
|
88
90
|
return;
|
package/dist/fast-element.d.ts
CHANGED
|
@@ -663,7 +663,13 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
663
663
|
private needsInitialization;
|
|
664
664
|
private hasExistingShadowRoot;
|
|
665
665
|
private _template;
|
|
666
|
-
private
|
|
666
|
+
private stage;
|
|
667
|
+
/**
|
|
668
|
+
* A guard against connecting behaviors multiple times
|
|
669
|
+
* during connect in scenarios where a behavior adds
|
|
670
|
+
* another behavior during it's connectedCallback
|
|
671
|
+
*/
|
|
672
|
+
private guardBehaviorConnection;
|
|
667
673
|
private behaviors;
|
|
668
674
|
private _mainStyles;
|
|
669
675
|
/**
|
|
@@ -695,7 +701,6 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
695
701
|
* connected to the document.
|
|
696
702
|
*/
|
|
697
703
|
get isConnected(): boolean;
|
|
698
|
-
private setIsConnected;
|
|
699
704
|
/**
|
|
700
705
|
* Gets/sets the template used to render the component.
|
|
701
706
|
* @remarks
|
|
@@ -755,6 +760,7 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
755
760
|
* Only emits events if connected.
|
|
756
761
|
*/
|
|
757
762
|
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
|
|
763
|
+
/* Excluded from this release type: toJSON */
|
|
758
764
|
private renderTemplate;
|
|
759
765
|
/**
|
|
760
766
|
* Locates or creates a controller for the specified element.
|
|
@@ -1505,6 +1511,7 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
|
|
|
1505
1511
|
* Unbinds a view's behaviors from its binding source.
|
|
1506
1512
|
*/
|
|
1507
1513
|
unbind(): void;
|
|
1514
|
+
/* Excluded from this release type: toJSON */
|
|
1508
1515
|
private evaluateUnbindables;
|
|
1509
1516
|
/**
|
|
1510
1517
|
* Efficiently disposes of a contiguous range of synthetic view instances.
|
|
@@ -1600,7 +1607,7 @@ export declare interface NodeBehaviorOptions<T = any> {
|
|
|
1600
1607
|
* Internally used by the SlottedDirective and the ChildrenDirective.
|
|
1601
1608
|
*/
|
|
1602
1609
|
export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
|
|
1603
|
-
private
|
|
1610
|
+
private controllerProperty;
|
|
1604
1611
|
/**
|
|
1605
1612
|
* Bind this behavior to the source.
|
|
1606
1613
|
* @param source - The source to bind to.
|
|
@@ -2262,6 +2269,7 @@ export declare abstract class StatelessAttachedAttributeDirective<TOptions> impl
|
|
|
2262
2269
|
* The structural id of the DOM node to which the created behavior will apply.
|
|
2263
2270
|
*/
|
|
2264
2271
|
nodeId: string;
|
|
2272
|
+
/* Excluded from this release type: toJSON */
|
|
2265
2273
|
/**
|
|
2266
2274
|
* Creates an instance of RefDirective.
|
|
2267
2275
|
* @param options - The options to use in configuring the directive.
|
|
@@ -2684,6 +2692,7 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
|
|
|
2684
2692
|
* host that the template is being attached to.
|
|
2685
2693
|
*/
|
|
2686
2694
|
render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
|
|
2695
|
+
/* Excluded from this release type: toJSON */
|
|
2687
2696
|
}
|
|
2688
2697
|
|
|
2689
2698
|
/**
|