@microsoft/fast-element 2.0.0-beta.23 → 2.0.0-beta.25
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 +74 -0
- package/CHANGELOG.md +23 -1
- package/dist/dts/dom.d.ts +1 -1
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +1 -1
- package/dist/dts/templating/when.d.ts +3 -1
- package/dist/esm/binding/two-way.js +2 -1
- package/dist/esm/components/element-controller.js +39 -9
- package/dist/esm/observation/arrays.js +1 -1
- package/dist/esm/observation/observable.js +1 -1
- package/dist/esm/templating/children.js +2 -2
- package/dist/esm/templating/compiler.js +3 -0
- package/dist/esm/templating/when.js +12 -5
- package/dist/fast-element.api.json +48 -9
- package/dist/fast-element.d.ts +6 -4
- package/dist/fast-element.debug.js +62 -22
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +62 -22
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +6 -4
- package/docs/api-report.md +4 -4
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-element",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Sat, 12 Aug 2023 00:26:36 GMT",
|
|
6
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.25",
|
|
7
|
+
"version": "2.0.0-beta.25",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
12
|
+
"package": "@microsoft/fast-element",
|
|
13
|
+
"commit": "ff0b93a7fb4ca416629f51cc233078494aaf5f60",
|
|
14
|
+
"comment": "Prevent notification of array splices when operation does not mutate array values"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
18
|
+
"package": "@microsoft/fast-element",
|
|
19
|
+
"commit": "9f6451f7e7c121d76e2ead6f50f77c312a0157f7",
|
|
20
|
+
"comment": "Adds volatile binding support for JavaScript optional chaining syntax"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Fri, 16 Jun 2023 18:17:12 GMT",
|
|
27
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.24",
|
|
28
|
+
"version": "2.0.0-beta.24",
|
|
29
|
+
"comments": {
|
|
30
|
+
"prerelease": [
|
|
31
|
+
{
|
|
32
|
+
"author": "chhol@microsoft.com",
|
|
33
|
+
"package": "@microsoft/fast-element",
|
|
34
|
+
"commit": "8250aa8352940584ff443b550ee756d49f01c478",
|
|
35
|
+
"comment": "fix: update compiler to ensure first and last child references are defined"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
39
|
+
"package": "@microsoft/fast-element",
|
|
40
|
+
"commit": "e678a782dd06a1c9ca79726da4a5765244858d21",
|
|
41
|
+
"comment": "Adds 'else' template option to the when directive"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
45
|
+
"package": "@microsoft/fast-element",
|
|
46
|
+
"commit": "58f7ce2ca73cf59dd957889e0763f45d087c77c9",
|
|
47
|
+
"comment": "fixed a bug where re-binding a ChildrenDirective instance would throw a runtime exception from the mutation handler"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
51
|
+
"package": "@microsoft/fast-element",
|
|
52
|
+
"commit": "88a0d7feb71b2452fa521b72ce308b1e499dfd94",
|
|
53
|
+
"comment": "Update adoptedStyleSheets strategy to use push/splice when available to fix Safari 16.4 bug"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
57
|
+
"package": "@microsoft/fast-element",
|
|
58
|
+
"commit": "9793634f3d06316a6a8689a909f4d41bdd667e99",
|
|
59
|
+
"comment": "fixes a bug where ChildrenDirective could not be used multiple times for the same element"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
63
|
+
"package": "@microsoft/fast-element",
|
|
64
|
+
"commit": "86c1952373b1fa0d7100cf0d8e942a0580cda725",
|
|
65
|
+
"comment": "fixed bug causing behaviors attached to stylesheets not to be removed when the stylesheet was removed"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"none": [
|
|
69
|
+
{
|
|
70
|
+
"author": "chhol@microsoft.com",
|
|
71
|
+
"package": "@microsoft/fast-element",
|
|
72
|
+
"commit": "ca0e62ee8d05f72d1d8c1ad66bd6eea8e3f0a4eb",
|
|
73
|
+
"comment": "update prettier and eslint-config-prettier versions"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
4
78
|
{
|
|
5
79
|
"date": "Tue, 28 Mar 2023 22:14:10 GMT",
|
|
6
80
|
"tag": "@microsoft/fast-element_v2.0.0-beta.23",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
# Change Log - @microsoft/fast-element
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 12 Aug 2023 00:26:36 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.0.0-beta.25
|
|
8
|
+
|
|
9
|
+
Sat, 12 Aug 2023 00:26:36 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- Prevent notification of array splices when operation does not mutate array values (nicholasrice@users.noreply.github.com)
|
|
14
|
+
- Adds volatile binding support for JavaScript optional chaining syntax (nicholasrice@users.noreply.github.com)
|
|
15
|
+
|
|
16
|
+
## 2.0.0-beta.24
|
|
17
|
+
|
|
18
|
+
Fri, 16 Jun 2023 18:17:12 GMT
|
|
19
|
+
|
|
20
|
+
### Changes
|
|
21
|
+
|
|
22
|
+
- fix: update compiler to ensure first and last child references are defined (chhol@microsoft.com)
|
|
23
|
+
- Adds 'else' template option to the when directive (nicholasrice@users.noreply.github.com)
|
|
24
|
+
- fixed a bug where re-binding a ChildrenDirective instance would throw a runtime exception from the mutation handler (nicholasrice@users.noreply.github.com)
|
|
25
|
+
- Update adoptedStyleSheets strategy to use push/splice when available to fix Safari 16.4 bug (nicholasrice@users.noreply.github.com)
|
|
26
|
+
- fixes a bug where ChildrenDirective could not be used multiple times for the same element (nicholasrice@users.noreply.github.com)
|
|
27
|
+
- fixed bug causing behaviors attached to stylesheets not to be removed when the stylesheet was removed (nicholasrice@users.noreply.github.com)
|
|
28
|
+
|
|
7
29
|
## 2.0.0-beta.23
|
|
8
30
|
|
|
9
31
|
Tue, 28 Mar 2023 22:14:10 GMT
|
package/dist/dts/dom.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare const DOMAspect: Readonly<{
|
|
|
36
36
|
* The type of HTML aspect to target.
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
|
-
export declare type DOMAspect = typeof DOMAspect[Exclude<keyof typeof DOMAspect, "none">];
|
|
39
|
+
export declare type DOMAspect = (typeof DOMAspect)[Exclude<keyof typeof DOMAspect, "none">];
|
|
40
40
|
/**
|
|
41
41
|
* A function used to send values to a DOM sink.
|
|
42
42
|
* @public
|
|
@@ -57,7 +57,7 @@ export declare const SpliceStrategySupport: Readonly<{
|
|
|
57
57
|
* The available values for SpliceStrategySupport.
|
|
58
58
|
* @public
|
|
59
59
|
*/
|
|
60
|
-
export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof typeof SpliceStrategySupport];
|
|
60
|
+
export declare type SpliceStrategySupport = (typeof SpliceStrategySupport)[keyof typeof SpliceStrategySupport];
|
|
61
61
|
/**
|
|
62
62
|
* An approach to tracking changes in an array.
|
|
63
63
|
* @public
|
|
@@ -60,7 +60,7 @@ export declare const SourceLifetime: Readonly<{
|
|
|
60
60
|
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
61
61
|
* @public
|
|
62
62
|
*/
|
|
63
|
-
export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
|
|
63
|
+
export declare type SourceLifetime = (typeof SourceLifetime)[keyof typeof SourceLifetime];
|
|
64
64
|
/**
|
|
65
65
|
* Controls the lifecycle of an expression and provides relevant context.
|
|
66
66
|
* @public
|
|
@@ -5,6 +5,8 @@ import type { CaptureType, SyntheticViewTemplate } from "./template.js";
|
|
|
5
5
|
* @param condition - The condition to test for rendering.
|
|
6
6
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
7
7
|
* the template to render when the condition is true.
|
|
8
|
+
* @param elseTemplateOrTemplateBinding - Optional template or binding that that
|
|
9
|
+
* gets the template to render when the conditional is false.
|
|
8
10
|
* @public
|
|
9
11
|
*/
|
|
10
|
-
export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
|
|
12
|
+
export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>, elseTemplateOrTemplateBinding?: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
|
|
@@ -74,7 +74,8 @@ class TwoWayObserver {
|
|
|
74
74
|
value = target[bindingSource.targetAspect];
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
last.propertySource[last.propertyName] =
|
|
77
|
+
last.propertySource[last.propertyName] =
|
|
78
|
+
this.dataBinding.options.fromView(value);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
makeSerializationNoop(TwoWayObserver);
|
|
@@ -278,7 +278,7 @@ export class ElementController extends PropertyChangeNotifier {
|
|
|
278
278
|
styles.removeStylesFrom(source);
|
|
279
279
|
if (sourceBehaviors !== null) {
|
|
280
280
|
for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
|
|
281
|
-
this.
|
|
281
|
+
this.removeBehavior(sourceBehaviors[i]);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -466,13 +466,10 @@ export class AdoptedStyleSheetsStrategy {
|
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
468
|
addStylesTo(target) {
|
|
469
|
-
|
|
470
|
-
t.adoptedStyleSheets = [...t.adoptedStyleSheets, ...this.sheets];
|
|
469
|
+
addAdoptedStyleSheets(normalizeStyleTarget(target), this.sheets);
|
|
471
470
|
}
|
|
472
471
|
removeStylesFrom(target) {
|
|
473
|
-
|
|
474
|
-
const sheets = this.sheets;
|
|
475
|
-
t.adoptedStyleSheets = t.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
|
|
472
|
+
removeAdoptedStyleSheets(normalizeStyleTarget(target), this.sheets);
|
|
476
473
|
}
|
|
477
474
|
}
|
|
478
475
|
AdoptedStyleSheetsStrategy.styleSheetCache = new Map();
|
|
@@ -508,6 +505,39 @@ export class StyleElementStrategy {
|
|
|
508
505
|
}
|
|
509
506
|
}
|
|
510
507
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
508
|
+
let addAdoptedStyleSheets = (target, sheets) => {
|
|
509
|
+
target.adoptedStyleSheets = [...target.adoptedStyleSheets, ...sheets];
|
|
510
|
+
};
|
|
511
|
+
let removeAdoptedStyleSheets = (target, sheets) => {
|
|
512
|
+
target.adoptedStyleSheets = target.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
|
|
513
|
+
};
|
|
514
|
+
if (ElementStyles.supportsAdoptedStyleSheets) {
|
|
515
|
+
try {
|
|
516
|
+
// Test if browser implementation uses FrozenArray.
|
|
517
|
+
// If not, use push / splice to alter the stylesheets
|
|
518
|
+
// in place. This circumvents a bug in Safari 16.4 where
|
|
519
|
+
// periodically, assigning the array would previously
|
|
520
|
+
// cause sheets to be removed.
|
|
521
|
+
document.adoptedStyleSheets.push();
|
|
522
|
+
document.adoptedStyleSheets.splice();
|
|
523
|
+
addAdoptedStyleSheets = (target, sheets) => {
|
|
524
|
+
target.adoptedStyleSheets.push(...sheets);
|
|
525
|
+
};
|
|
526
|
+
removeAdoptedStyleSheets = (target, sheets) => {
|
|
527
|
+
for (const sheet of sheets) {
|
|
528
|
+
const index = target.adoptedStyleSheets.indexOf(sheet);
|
|
529
|
+
if (index !== -1) {
|
|
530
|
+
target.adoptedStyleSheets.splice(index, 1);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
catch (e) {
|
|
536
|
+
// Do nothing if an error is thrown, the default
|
|
537
|
+
// case handles FrozenArray.
|
|
538
|
+
}
|
|
539
|
+
ElementStyles.setDefaultStrategy(AdoptedStyleSheetsStrategy);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
ElementStyles.setDefaultStrategy(StyleElementStrategy);
|
|
543
|
+
}
|
|
@@ -23,7 +23,7 @@ export const SourceLifetime = Object.freeze({
|
|
|
23
23
|
*/
|
|
24
24
|
export const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
25
25
|
const queueUpdate = Updates.enqueue;
|
|
26
|
-
const volatileRegex = /(:|&&|\|\||if)/;
|
|
26
|
+
const volatileRegex = /(:|&&|\|\||if|\?\.)/;
|
|
27
27
|
const notifierLookup = new WeakMap();
|
|
28
28
|
let watcher = void 0;
|
|
29
29
|
let createArrayObserver = (array) => {
|
|
@@ -12,7 +12,7 @@ export class ChildrenDirective extends NodeObservationDirective {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(options) {
|
|
14
14
|
super(options);
|
|
15
|
-
this.observerProperty =
|
|
15
|
+
this.observerProperty = Symbol();
|
|
16
16
|
this.handleEvent = (mutations, observer) => {
|
|
17
17
|
const target = observer.target;
|
|
18
18
|
this.updateTarget(this.getSource(target), this.computeNodes(target));
|
|
@@ -28,9 +28,9 @@ export class ChildrenDirective extends NodeObservationDirective {
|
|
|
28
28
|
if (!observer) {
|
|
29
29
|
observer = new MutationObserver(this.handleEvent);
|
|
30
30
|
observer.toJSON = noop;
|
|
31
|
-
observer.target = target;
|
|
32
31
|
target[this.observerProperty] = observer;
|
|
33
32
|
}
|
|
33
|
+
observer.target = target;
|
|
34
34
|
observer.observe(target, this.options);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -215,6 +215,9 @@ export const Compiler = {
|
|
|
215
215
|
else {
|
|
216
216
|
template = html;
|
|
217
217
|
}
|
|
218
|
+
if (!template.content.firstChild && !template.content.lastChild) {
|
|
219
|
+
template.content.appendChild(document.createComment(""));
|
|
220
|
+
}
|
|
218
221
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1111864
|
|
219
222
|
const fragment = document.adoptNode(template.content);
|
|
220
223
|
const context = new CompilationContext(fragment, factories, policy);
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { isFunction } from "../interfaces.js";
|
|
2
|
+
const noTemplate = () => null;
|
|
3
|
+
function normalizeBinding(value) {
|
|
4
|
+
return value === undefined ? noTemplate : isFunction(value) ? value : () => value;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* A directive that enables basic conditional rendering in a template.
|
|
4
8
|
* @param condition - The condition to test for rendering.
|
|
5
9
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
6
10
|
* the template to render when the condition is true.
|
|
11
|
+
* @param elseTemplateOrTemplateBinding - Optional template or binding that that
|
|
12
|
+
* gets the template to render when the conditional is false.
|
|
7
13
|
* @public
|
|
8
14
|
*/
|
|
9
|
-
export function when(condition, templateOrTemplateBinding) {
|
|
15
|
+
export function when(condition, templateOrTemplateBinding, elseTemplateOrTemplateBinding) {
|
|
10
16
|
const dataBinding = isFunction(condition) ? condition : () => condition;
|
|
11
|
-
const templateBinding =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
const templateBinding = normalizeBinding(templateOrTemplateBinding);
|
|
18
|
+
const elseBinding = normalizeBinding(elseTemplateOrTemplateBinding);
|
|
19
|
+
return (source, context) => dataBinding(source, context)
|
|
20
|
+
? templateBinding(source, context)
|
|
21
|
+
: elseBinding(source, context);
|
|
15
22
|
}
|
|
@@ -4183,7 +4183,7 @@
|
|
|
4183
4183
|
},
|
|
4184
4184
|
{
|
|
4185
4185
|
"kind": "Content",
|
|
4186
|
-
"text": "typeof "
|
|
4186
|
+
"text": "(typeof "
|
|
4187
4187
|
},
|
|
4188
4188
|
{
|
|
4189
4189
|
"kind": "Reference",
|
|
@@ -4192,7 +4192,7 @@
|
|
|
4192
4192
|
},
|
|
4193
4193
|
{
|
|
4194
4194
|
"kind": "Content",
|
|
4195
|
-
"text": "["
|
|
4195
|
+
"text": ")["
|
|
4196
4196
|
},
|
|
4197
4197
|
{
|
|
4198
4198
|
"kind": "Reference",
|
|
@@ -15509,7 +15509,7 @@
|
|
|
15509
15509
|
},
|
|
15510
15510
|
{
|
|
15511
15511
|
"kind": "Content",
|
|
15512
|
-
"text": "typeof "
|
|
15512
|
+
"text": "(typeof "
|
|
15513
15513
|
},
|
|
15514
15514
|
{
|
|
15515
15515
|
"kind": "Reference",
|
|
@@ -15518,7 +15518,7 @@
|
|
|
15518
15518
|
},
|
|
15519
15519
|
{
|
|
15520
15520
|
"kind": "Content",
|
|
15521
|
-
"text": "[keyof typeof "
|
|
15521
|
+
"text": ")[keyof typeof "
|
|
15522
15522
|
},
|
|
15523
15523
|
{
|
|
15524
15524
|
"kind": "Reference",
|
|
@@ -16682,7 +16682,7 @@
|
|
|
16682
16682
|
},
|
|
16683
16683
|
{
|
|
16684
16684
|
"kind": "Content",
|
|
16685
|
-
"text": "typeof "
|
|
16685
|
+
"text": "(typeof "
|
|
16686
16686
|
},
|
|
16687
16687
|
{
|
|
16688
16688
|
"kind": "Reference",
|
|
@@ -16691,7 +16691,7 @@
|
|
|
16691
16691
|
},
|
|
16692
16692
|
{
|
|
16693
16693
|
"kind": "Content",
|
|
16694
|
-
"text": "[keyof typeof "
|
|
16694
|
+
"text": ")[keyof typeof "
|
|
16695
16695
|
},
|
|
16696
16696
|
{
|
|
16697
16697
|
"kind": "Reference",
|
|
@@ -19888,7 +19888,7 @@
|
|
|
19888
19888
|
{
|
|
19889
19889
|
"kind": "Function",
|
|
19890
19890
|
"canonicalReference": "@microsoft/fast-element!when:function(1)",
|
|
19891
|
-
"docComment": "/**\n * A directive that enables basic conditional rendering in a template.\n *\n * @param condition - The condition to test for rendering.\n *\n * @param templateOrTemplateBinding - The template or a binding that gets the template to render when the condition is true.\n *\n * @public\n */\n",
|
|
19891
|
+
"docComment": "/**\n * A directive that enables basic conditional rendering in a template.\n *\n * @param condition - The condition to test for rendering.\n *\n * @param templateOrTemplateBinding - The template or a binding that gets the template to render when the condition is true.\n *\n * @param elseTemplateOrTemplateBinding - Optional template or binding that that gets the template to render when the conditional is false.\n *\n * @public\n */\n",
|
|
19892
19892
|
"excerptTokens": [
|
|
19893
19893
|
{
|
|
19894
19894
|
"kind": "Content",
|
|
@@ -19958,6 +19958,37 @@
|
|
|
19958
19958
|
"kind": "Content",
|
|
19959
19959
|
"text": "<TSource, TParent>, TParent>"
|
|
19960
19960
|
},
|
|
19961
|
+
{
|
|
19962
|
+
"kind": "Content",
|
|
19963
|
+
"text": ", elseTemplateOrTemplateBinding?: "
|
|
19964
|
+
},
|
|
19965
|
+
{
|
|
19966
|
+
"kind": "Reference",
|
|
19967
|
+
"text": "SyntheticViewTemplate",
|
|
19968
|
+
"canonicalReference": "@microsoft/fast-element!SyntheticViewTemplate:interface"
|
|
19969
|
+
},
|
|
19970
|
+
{
|
|
19971
|
+
"kind": "Content",
|
|
19972
|
+
"text": "<TSource, TParent> | "
|
|
19973
|
+
},
|
|
19974
|
+
{
|
|
19975
|
+
"kind": "Reference",
|
|
19976
|
+
"text": "Expression",
|
|
19977
|
+
"canonicalReference": "@microsoft/fast-element!Expression:type"
|
|
19978
|
+
},
|
|
19979
|
+
{
|
|
19980
|
+
"kind": "Content",
|
|
19981
|
+
"text": "<TSource, "
|
|
19982
|
+
},
|
|
19983
|
+
{
|
|
19984
|
+
"kind": "Reference",
|
|
19985
|
+
"text": "SyntheticViewTemplate",
|
|
19986
|
+
"canonicalReference": "@microsoft/fast-element!SyntheticViewTemplate:interface"
|
|
19987
|
+
},
|
|
19988
|
+
{
|
|
19989
|
+
"kind": "Content",
|
|
19990
|
+
"text": "<TSource, TParent>, TParent>"
|
|
19991
|
+
},
|
|
19961
19992
|
{
|
|
19962
19993
|
"kind": "Content",
|
|
19963
19994
|
"text": "): "
|
|
@@ -19977,8 +20008,8 @@
|
|
|
19977
20008
|
}
|
|
19978
20009
|
],
|
|
19979
20010
|
"returnTypeTokenRange": {
|
|
19980
|
-
"startIndex":
|
|
19981
|
-
"endIndex":
|
|
20011
|
+
"startIndex": 24,
|
|
20012
|
+
"endIndex": 26
|
|
19982
20013
|
},
|
|
19983
20014
|
"releaseTag": "Public",
|
|
19984
20015
|
"overloadIndex": 1,
|
|
@@ -19998,6 +20029,14 @@
|
|
|
19998
20029
|
"endIndex": 16
|
|
19999
20030
|
},
|
|
20000
20031
|
"isOptional": false
|
|
20032
|
+
},
|
|
20033
|
+
{
|
|
20034
|
+
"parameterName": "elseTemplateOrTemplateBinding",
|
|
20035
|
+
"parameterTypeTokenRange": {
|
|
20036
|
+
"startIndex": 17,
|
|
20037
|
+
"endIndex": 23
|
|
20038
|
+
},
|
|
20039
|
+
"isOptional": true
|
|
20001
20040
|
}
|
|
20002
20041
|
],
|
|
20003
20042
|
"typeParameters": [
|
package/dist/fast-element.d.ts
CHANGED
|
@@ -713,7 +713,7 @@ export declare const DOMAspect: Readonly<{
|
|
|
713
713
|
* The type of HTML aspect to target.
|
|
714
714
|
* @public
|
|
715
715
|
*/
|
|
716
|
-
export declare type DOMAspect = typeof DOMAspect[Exclude<keyof typeof DOMAspect, "none">];
|
|
716
|
+
export declare type DOMAspect = (typeof DOMAspect)[Exclude<keyof typeof DOMAspect, "none">];
|
|
717
717
|
|
|
718
718
|
/**
|
|
719
719
|
* A security policy that FAST can use to interact with the DOM.
|
|
@@ -2334,7 +2334,7 @@ export declare const SourceLifetime: Readonly<{
|
|
|
2334
2334
|
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
2335
2335
|
* @public
|
|
2336
2336
|
*/
|
|
2337
|
-
export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
|
|
2337
|
+
export declare type SourceLifetime = (typeof SourceLifetime)[keyof typeof SourceLifetime];
|
|
2338
2338
|
|
|
2339
2339
|
/**
|
|
2340
2340
|
* A splice map is a representation of how a previous array of items
|
|
@@ -2486,7 +2486,7 @@ export declare const SpliceStrategySupport: Readonly<{
|
|
|
2486
2486
|
* The available values for SpliceStrategySupport.
|
|
2487
2487
|
* @public
|
|
2488
2488
|
*/
|
|
2489
|
-
export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof typeof SpliceStrategySupport];
|
|
2489
|
+
export declare type SpliceStrategySupport = (typeof SpliceStrategySupport)[keyof typeof SpliceStrategySupport];
|
|
2490
2490
|
|
|
2491
2491
|
/**
|
|
2492
2492
|
* A base class used for attribute directives that don't need internal state.
|
|
@@ -2921,8 +2921,10 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
2921
2921
|
* @param condition - The condition to test for rendering.
|
|
2922
2922
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
2923
2923
|
* the template to render when the condition is true.
|
|
2924
|
+
* @param elseTemplateOrTemplateBinding - Optional template or binding that that
|
|
2925
|
+
* gets the template to render when the conditional is false.
|
|
2924
2926
|
* @public
|
|
2925
2927
|
*/
|
|
2926
|
-
export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
|
|
2928
|
+
export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>, elseTemplateOrTemplateBinding?: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
|
|
2927
2929
|
|
|
2928
2930
|
export { }
|
|
@@ -941,7 +941,7 @@ const SourceLifetime = Object.freeze({
|
|
|
941
941
|
*/
|
|
942
942
|
const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
943
943
|
const queueUpdate = Updates.enqueue;
|
|
944
|
-
const volatileRegex = /(:|&&|\|\||if)/;
|
|
944
|
+
const volatileRegex = /(:|&&|\|\||if|\?\.)/;
|
|
945
945
|
const notifierLookup = new WeakMap();
|
|
946
946
|
let watcher = void 0;
|
|
947
947
|
let createArrayObserver = (array) => {
|
|
@@ -1622,7 +1622,7 @@ let defaultSpliceStrategy = Object.freeze({
|
|
|
1622
1622
|
if (changes === void 0) {
|
|
1623
1623
|
return emptyArray;
|
|
1624
1624
|
}
|
|
1625
|
-
return
|
|
1625
|
+
return project(current, changes);
|
|
1626
1626
|
}
|
|
1627
1627
|
return resetSplices;
|
|
1628
1628
|
},
|
|
@@ -1896,7 +1896,7 @@ function oneTime(expression, policy) {
|
|
|
1896
1896
|
* @returns A binding configuration for the provided value.
|
|
1897
1897
|
* @public
|
|
1898
1898
|
*/
|
|
1899
|
-
function normalizeBinding(value) {
|
|
1899
|
+
function normalizeBinding$1(value) {
|
|
1900
1900
|
return isFunction(value)
|
|
1901
1901
|
? oneWay(value)
|
|
1902
1902
|
: value instanceof Binding
|
|
@@ -3014,6 +3014,9 @@ const Compiler = {
|
|
|
3014
3014
|
else {
|
|
3015
3015
|
template = html;
|
|
3016
3016
|
}
|
|
3017
|
+
if (!template.content.firstChild && !template.content.lastChild) {
|
|
3018
|
+
template.content.appendChild(document.createComment(""));
|
|
3019
|
+
}
|
|
3017
3020
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1111864
|
|
3018
3021
|
const fragment = document.adoptNode(template.content);
|
|
3019
3022
|
const context = new CompilationContext(fragment, factories, policy);
|
|
@@ -3275,19 +3278,26 @@ HTMLDirective.define(RefDirective);
|
|
|
3275
3278
|
*/
|
|
3276
3279
|
const ref = (propertyName) => new RefDirective(propertyName);
|
|
3277
3280
|
|
|
3281
|
+
const noTemplate = () => null;
|
|
3282
|
+
function normalizeBinding(value) {
|
|
3283
|
+
return value === undefined ? noTemplate : isFunction(value) ? value : () => value;
|
|
3284
|
+
}
|
|
3278
3285
|
/**
|
|
3279
3286
|
* A directive that enables basic conditional rendering in a template.
|
|
3280
3287
|
* @param condition - The condition to test for rendering.
|
|
3281
3288
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
3282
3289
|
* the template to render when the condition is true.
|
|
3290
|
+
* @param elseTemplateOrTemplateBinding - Optional template or binding that that
|
|
3291
|
+
* gets the template to render when the conditional is false.
|
|
3283
3292
|
* @public
|
|
3284
3293
|
*/
|
|
3285
|
-
function when(condition, templateOrTemplateBinding) {
|
|
3294
|
+
function when(condition, templateOrTemplateBinding, elseTemplateOrTemplateBinding) {
|
|
3286
3295
|
const dataBinding = isFunction(condition) ? condition : () => condition;
|
|
3287
|
-
const templateBinding =
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3296
|
+
const templateBinding = normalizeBinding(templateOrTemplateBinding);
|
|
3297
|
+
const elseBinding = normalizeBinding(elseTemplateOrTemplateBinding);
|
|
3298
|
+
return (source, context) => dataBinding(source, context)
|
|
3299
|
+
? templateBinding(source, context)
|
|
3300
|
+
: elseBinding(source, context);
|
|
3291
3301
|
}
|
|
3292
3302
|
|
|
3293
3303
|
const defaultRepeatOptions = Object.freeze({
|
|
@@ -3545,8 +3555,8 @@ HTMLDirective.define(RepeatDirective);
|
|
|
3545
3555
|
* @public
|
|
3546
3556
|
*/
|
|
3547
3557
|
function repeat(items, template, options = defaultRepeatOptions) {
|
|
3548
|
-
const dataBinding = normalizeBinding(items);
|
|
3549
|
-
const templateBinding = normalizeBinding(template);
|
|
3558
|
+
const dataBinding = normalizeBinding$1(items);
|
|
3559
|
+
const templateBinding = normalizeBinding$1(template);
|
|
3550
3560
|
return new RepeatDirective(dataBinding, templateBinding, Object.assign(Object.assign({}, defaultRepeatOptions), options));
|
|
3551
3561
|
}
|
|
3552
3562
|
|
|
@@ -3691,7 +3701,7 @@ class ChildrenDirective extends NodeObservationDirective {
|
|
|
3691
3701
|
*/
|
|
3692
3702
|
constructor(options) {
|
|
3693
3703
|
super(options);
|
|
3694
|
-
this.observerProperty =
|
|
3704
|
+
this.observerProperty = Symbol();
|
|
3695
3705
|
this.handleEvent = (mutations, observer) => {
|
|
3696
3706
|
const target = observer.target;
|
|
3697
3707
|
this.updateTarget(this.getSource(target), this.computeNodes(target));
|
|
@@ -3707,9 +3717,9 @@ class ChildrenDirective extends NodeObservationDirective {
|
|
|
3707
3717
|
if (!observer) {
|
|
3708
3718
|
observer = new MutationObserver(this.handleEvent);
|
|
3709
3719
|
observer.toJSON = noop;
|
|
3710
|
-
observer.target = target;
|
|
3711
3720
|
target[this.observerProperty] = observer;
|
|
3712
3721
|
}
|
|
3722
|
+
observer.target = target;
|
|
3713
3723
|
observer.observe(target, this.options);
|
|
3714
3724
|
}
|
|
3715
3725
|
/**
|
|
@@ -4335,7 +4345,7 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4335
4345
|
styles.removeStylesFrom(source);
|
|
4336
4346
|
if (sourceBehaviors !== null) {
|
|
4337
4347
|
for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
|
|
4338
|
-
this.
|
|
4348
|
+
this.removeBehavior(sourceBehaviors[i]);
|
|
4339
4349
|
}
|
|
4340
4350
|
}
|
|
4341
4351
|
}
|
|
@@ -4523,13 +4533,10 @@ class AdoptedStyleSheetsStrategy {
|
|
|
4523
4533
|
});
|
|
4524
4534
|
}
|
|
4525
4535
|
addStylesTo(target) {
|
|
4526
|
-
|
|
4527
|
-
t.adoptedStyleSheets = [...t.adoptedStyleSheets, ...this.sheets];
|
|
4536
|
+
addAdoptedStyleSheets(normalizeStyleTarget(target), this.sheets);
|
|
4528
4537
|
}
|
|
4529
4538
|
removeStylesFrom(target) {
|
|
4530
|
-
|
|
4531
|
-
const sheets = this.sheets;
|
|
4532
|
-
t.adoptedStyleSheets = t.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
|
|
4539
|
+
removeAdoptedStyleSheets(normalizeStyleTarget(target), this.sheets);
|
|
4533
4540
|
}
|
|
4534
4541
|
}
|
|
4535
4542
|
AdoptedStyleSheetsStrategy.styleSheetCache = new Map();
|
|
@@ -4565,9 +4572,42 @@ class StyleElementStrategy {
|
|
|
4565
4572
|
}
|
|
4566
4573
|
}
|
|
4567
4574
|
}
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4575
|
+
let addAdoptedStyleSheets = (target, sheets) => {
|
|
4576
|
+
target.adoptedStyleSheets = [...target.adoptedStyleSheets, ...sheets];
|
|
4577
|
+
};
|
|
4578
|
+
let removeAdoptedStyleSheets = (target, sheets) => {
|
|
4579
|
+
target.adoptedStyleSheets = target.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
|
|
4580
|
+
};
|
|
4581
|
+
if (ElementStyles.supportsAdoptedStyleSheets) {
|
|
4582
|
+
try {
|
|
4583
|
+
// Test if browser implementation uses FrozenArray.
|
|
4584
|
+
// If not, use push / splice to alter the stylesheets
|
|
4585
|
+
// in place. This circumvents a bug in Safari 16.4 where
|
|
4586
|
+
// periodically, assigning the array would previously
|
|
4587
|
+
// cause sheets to be removed.
|
|
4588
|
+
document.adoptedStyleSheets.push();
|
|
4589
|
+
document.adoptedStyleSheets.splice();
|
|
4590
|
+
addAdoptedStyleSheets = (target, sheets) => {
|
|
4591
|
+
target.adoptedStyleSheets.push(...sheets);
|
|
4592
|
+
};
|
|
4593
|
+
removeAdoptedStyleSheets = (target, sheets) => {
|
|
4594
|
+
for (const sheet of sheets) {
|
|
4595
|
+
const index = target.adoptedStyleSheets.indexOf(sheet);
|
|
4596
|
+
if (index !== -1) {
|
|
4597
|
+
target.adoptedStyleSheets.splice(index, 1);
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
};
|
|
4601
|
+
}
|
|
4602
|
+
catch (e) {
|
|
4603
|
+
// Do nothing if an error is thrown, the default
|
|
4604
|
+
// case handles FrozenArray.
|
|
4605
|
+
}
|
|
4606
|
+
ElementStyles.setDefaultStrategy(AdoptedStyleSheetsStrategy);
|
|
4607
|
+
}
|
|
4608
|
+
else {
|
|
4609
|
+
ElementStyles.setDefaultStrategy(StyleElementStrategy);
|
|
4610
|
+
}
|
|
4571
4611
|
|
|
4572
4612
|
/* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
|
|
4573
4613
|
function createFASTElement(BaseType) {
|
|
@@ -4648,4 +4688,4 @@ function customElement(nameOrDef) {
|
|
|
4648
4688
|
|
|
4649
4689
|
DOM.setPolicy(DOMPolicy.create());
|
|
4650
4690
|
|
|
4651
|
-
export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RepeatBehavior, RepeatDirective, SlottedDirective, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, repeat, slotted, volatile, when };
|
|
4691
|
+
export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RepeatBehavior, RepeatDirective, SlottedDirective, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding$1 as normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, repeat, slotted, volatile, when };
|