@microsoft/fast-element 2.0.0-beta.22 → 2.0.0-beta.24
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/binding/signal.d.ts +15 -2
- package/dist/dts/binding/two-way.d.ts +3 -0
- package/dist/dts/context.d.ts +1 -1
- package/dist/dts/dom.d.ts +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/interfaces.d.ts +5 -0
- 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/signal.js +15 -2
- package/dist/esm/binding/two-way.js +5 -1
- package/dist/esm/components/element-controller.js +39 -9
- package/dist/esm/index.js +1 -0
- 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 +170 -9
- package/dist/fast-element.d.ts +14 -4
- package/dist/fast-element.debug.js +73 -33
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +73 -33
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +14 -4
- package/docs/api-report.md +7 -4
- package/package.json +2 -2
|
@@ -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",
|
|
@@ -12645,6 +12645,128 @@
|
|
|
12645
12645
|
},
|
|
12646
12646
|
"implementsTokenRanges": []
|
|
12647
12647
|
},
|
|
12648
|
+
{
|
|
12649
|
+
"kind": "Function",
|
|
12650
|
+
"canonicalReference": "@microsoft/fast-element!normalizeBinding:function(1)",
|
|
12651
|
+
"docComment": "/**\n * Normalizes the input value into a binding.\n *\n * @param value - The value to create the default binding for.\n *\n * @returns A binding configuration for the provided value.\n *\n * @public\n */\n",
|
|
12652
|
+
"excerptTokens": [
|
|
12653
|
+
{
|
|
12654
|
+
"kind": "Content",
|
|
12655
|
+
"text": "export declare function normalizeBinding<TSource = "
|
|
12656
|
+
},
|
|
12657
|
+
{
|
|
12658
|
+
"kind": "Content",
|
|
12659
|
+
"text": "any"
|
|
12660
|
+
},
|
|
12661
|
+
{
|
|
12662
|
+
"kind": "Content",
|
|
12663
|
+
"text": ", TReturn = "
|
|
12664
|
+
},
|
|
12665
|
+
{
|
|
12666
|
+
"kind": "Content",
|
|
12667
|
+
"text": "any"
|
|
12668
|
+
},
|
|
12669
|
+
{
|
|
12670
|
+
"kind": "Content",
|
|
12671
|
+
"text": ", TParent = "
|
|
12672
|
+
},
|
|
12673
|
+
{
|
|
12674
|
+
"kind": "Content",
|
|
12675
|
+
"text": "any"
|
|
12676
|
+
},
|
|
12677
|
+
{
|
|
12678
|
+
"kind": "Content",
|
|
12679
|
+
"text": ">(value: "
|
|
12680
|
+
},
|
|
12681
|
+
{
|
|
12682
|
+
"kind": "Reference",
|
|
12683
|
+
"text": "Expression",
|
|
12684
|
+
"canonicalReference": "@microsoft/fast-element!Expression:type"
|
|
12685
|
+
},
|
|
12686
|
+
{
|
|
12687
|
+
"kind": "Content",
|
|
12688
|
+
"text": "<TSource, TReturn, TParent> | "
|
|
12689
|
+
},
|
|
12690
|
+
{
|
|
12691
|
+
"kind": "Reference",
|
|
12692
|
+
"text": "Binding",
|
|
12693
|
+
"canonicalReference": "@microsoft/fast-element!Binding:class"
|
|
12694
|
+
},
|
|
12695
|
+
{
|
|
12696
|
+
"kind": "Content",
|
|
12697
|
+
"text": "<TSource, TReturn, TParent> | {}"
|
|
12698
|
+
},
|
|
12699
|
+
{
|
|
12700
|
+
"kind": "Content",
|
|
12701
|
+
"text": "): "
|
|
12702
|
+
},
|
|
12703
|
+
{
|
|
12704
|
+
"kind": "Reference",
|
|
12705
|
+
"text": "Binding",
|
|
12706
|
+
"canonicalReference": "@microsoft/fast-element!Binding:class"
|
|
12707
|
+
},
|
|
12708
|
+
{
|
|
12709
|
+
"kind": "Content",
|
|
12710
|
+
"text": "<TSource, TReturn, TParent>"
|
|
12711
|
+
},
|
|
12712
|
+
{
|
|
12713
|
+
"kind": "Content",
|
|
12714
|
+
"text": ";"
|
|
12715
|
+
}
|
|
12716
|
+
],
|
|
12717
|
+
"returnTypeTokenRange": {
|
|
12718
|
+
"startIndex": 12,
|
|
12719
|
+
"endIndex": 14
|
|
12720
|
+
},
|
|
12721
|
+
"releaseTag": "Public",
|
|
12722
|
+
"overloadIndex": 1,
|
|
12723
|
+
"parameters": [
|
|
12724
|
+
{
|
|
12725
|
+
"parameterName": "value",
|
|
12726
|
+
"parameterTypeTokenRange": {
|
|
12727
|
+
"startIndex": 7,
|
|
12728
|
+
"endIndex": 11
|
|
12729
|
+
},
|
|
12730
|
+
"isOptional": false
|
|
12731
|
+
}
|
|
12732
|
+
],
|
|
12733
|
+
"typeParameters": [
|
|
12734
|
+
{
|
|
12735
|
+
"typeParameterName": "TSource",
|
|
12736
|
+
"constraintTokenRange": {
|
|
12737
|
+
"startIndex": 0,
|
|
12738
|
+
"endIndex": 0
|
|
12739
|
+
},
|
|
12740
|
+
"defaultTypeTokenRange": {
|
|
12741
|
+
"startIndex": 1,
|
|
12742
|
+
"endIndex": 2
|
|
12743
|
+
}
|
|
12744
|
+
},
|
|
12745
|
+
{
|
|
12746
|
+
"typeParameterName": "TReturn",
|
|
12747
|
+
"constraintTokenRange": {
|
|
12748
|
+
"startIndex": 0,
|
|
12749
|
+
"endIndex": 0
|
|
12750
|
+
},
|
|
12751
|
+
"defaultTypeTokenRange": {
|
|
12752
|
+
"startIndex": 3,
|
|
12753
|
+
"endIndex": 4
|
|
12754
|
+
}
|
|
12755
|
+
},
|
|
12756
|
+
{
|
|
12757
|
+
"typeParameterName": "TParent",
|
|
12758
|
+
"constraintTokenRange": {
|
|
12759
|
+
"startIndex": 0,
|
|
12760
|
+
"endIndex": 0
|
|
12761
|
+
},
|
|
12762
|
+
"defaultTypeTokenRange": {
|
|
12763
|
+
"startIndex": 5,
|
|
12764
|
+
"endIndex": 6
|
|
12765
|
+
}
|
|
12766
|
+
}
|
|
12767
|
+
],
|
|
12768
|
+
"name": "normalizeBinding"
|
|
12769
|
+
},
|
|
12648
12770
|
{
|
|
12649
12771
|
"kind": "Interface",
|
|
12650
12772
|
"canonicalReference": "@microsoft/fast-element!Notifier:interface",
|
|
@@ -15387,7 +15509,7 @@
|
|
|
15387
15509
|
},
|
|
15388
15510
|
{
|
|
15389
15511
|
"kind": "Content",
|
|
15390
|
-
"text": "typeof "
|
|
15512
|
+
"text": "(typeof "
|
|
15391
15513
|
},
|
|
15392
15514
|
{
|
|
15393
15515
|
"kind": "Reference",
|
|
@@ -15396,7 +15518,7 @@
|
|
|
15396
15518
|
},
|
|
15397
15519
|
{
|
|
15398
15520
|
"kind": "Content",
|
|
15399
|
-
"text": "[keyof typeof "
|
|
15521
|
+
"text": ")[keyof typeof "
|
|
15400
15522
|
},
|
|
15401
15523
|
{
|
|
15402
15524
|
"kind": "Reference",
|
|
@@ -16560,7 +16682,7 @@
|
|
|
16560
16682
|
},
|
|
16561
16683
|
{
|
|
16562
16684
|
"kind": "Content",
|
|
16563
|
-
"text": "typeof "
|
|
16685
|
+
"text": "(typeof "
|
|
16564
16686
|
},
|
|
16565
16687
|
{
|
|
16566
16688
|
"kind": "Reference",
|
|
@@ -16569,7 +16691,7 @@
|
|
|
16569
16691
|
},
|
|
16570
16692
|
{
|
|
16571
16693
|
"kind": "Content",
|
|
16572
|
-
"text": "[keyof typeof "
|
|
16694
|
+
"text": ")[keyof typeof "
|
|
16573
16695
|
},
|
|
16574
16696
|
{
|
|
16575
16697
|
"kind": "Reference",
|
|
@@ -19766,7 +19888,7 @@
|
|
|
19766
19888
|
{
|
|
19767
19889
|
"kind": "Function",
|
|
19768
19890
|
"canonicalReference": "@microsoft/fast-element!when:function(1)",
|
|
19769
|
-
"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",
|
|
19770
19892
|
"excerptTokens": [
|
|
19771
19893
|
{
|
|
19772
19894
|
"kind": "Content",
|
|
@@ -19836,6 +19958,37 @@
|
|
|
19836
19958
|
"kind": "Content",
|
|
19837
19959
|
"text": "<TSource, TParent>, TParent>"
|
|
19838
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
|
+
},
|
|
19839
19992
|
{
|
|
19840
19993
|
"kind": "Content",
|
|
19841
19994
|
"text": "): "
|
|
@@ -19855,8 +20008,8 @@
|
|
|
19855
20008
|
}
|
|
19856
20009
|
],
|
|
19857
20010
|
"returnTypeTokenRange": {
|
|
19858
|
-
"startIndex":
|
|
19859
|
-
"endIndex":
|
|
20011
|
+
"startIndex": 24,
|
|
20012
|
+
"endIndex": 26
|
|
19860
20013
|
},
|
|
19861
20014
|
"releaseTag": "Public",
|
|
19862
20015
|
"overloadIndex": 1,
|
|
@@ -19876,6 +20029,14 @@
|
|
|
19876
20029
|
"endIndex": 16
|
|
19877
20030
|
},
|
|
19878
20031
|
"isOptional": false
|
|
20032
|
+
},
|
|
20033
|
+
{
|
|
20034
|
+
"parameterName": "elseTemplateOrTemplateBinding",
|
|
20035
|
+
"parameterTypeTokenRange": {
|
|
20036
|
+
"startIndex": 17,
|
|
20037
|
+
"endIndex": 23
|
|
20038
|
+
},
|
|
20039
|
+
"isOptional": true
|
|
19879
20040
|
}
|
|
19880
20041
|
],
|
|
19881
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.
|
|
@@ -1875,6 +1875,14 @@ export declare abstract class NodeObservationDirective<T extends NodeBehaviorOpt
|
|
|
1875
1875
|
protected abstract getNodes(target: any): Node[];
|
|
1876
1876
|
}
|
|
1877
1877
|
|
|
1878
|
+
/**
|
|
1879
|
+
* Normalizes the input value into a binding.
|
|
1880
|
+
* @param value - The value to create the default binding for.
|
|
1881
|
+
* @returns A binding configuration for the provided value.
|
|
1882
|
+
* @public
|
|
1883
|
+
*/
|
|
1884
|
+
export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
|
|
1885
|
+
|
|
1878
1886
|
/**
|
|
1879
1887
|
* Provides change notifications for an observed subject.
|
|
1880
1888
|
* @public
|
|
@@ -2326,7 +2334,7 @@ export declare const SourceLifetime: Readonly<{
|
|
|
2326
2334
|
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
2327
2335
|
* @public
|
|
2328
2336
|
*/
|
|
2329
|
-
export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
|
|
2337
|
+
export declare type SourceLifetime = (typeof SourceLifetime)[keyof typeof SourceLifetime];
|
|
2330
2338
|
|
|
2331
2339
|
/**
|
|
2332
2340
|
* A splice map is a representation of how a previous array of items
|
|
@@ -2478,7 +2486,7 @@ export declare const SpliceStrategySupport: Readonly<{
|
|
|
2478
2486
|
* The available values for SpliceStrategySupport.
|
|
2479
2487
|
* @public
|
|
2480
2488
|
*/
|
|
2481
|
-
export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof typeof SpliceStrategySupport];
|
|
2489
|
+
export declare type SpliceStrategySupport = (typeof SpliceStrategySupport)[keyof typeof SpliceStrategySupport];
|
|
2482
2490
|
|
|
2483
2491
|
/**
|
|
2484
2492
|
* A base class used for attribute directives that don't need internal state.
|
|
@@ -2913,8 +2921,10 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
2913
2921
|
* @param condition - The condition to test for rendering.
|
|
2914
2922
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
2915
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.
|
|
2916
2926
|
* @public
|
|
2917
2927
|
*/
|
|
2918
|
-
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>;
|
|
2919
2929
|
|
|
2920
2930
|
export { }
|
|
@@ -1890,6 +1890,20 @@ function oneTime(expression, policy) {
|
|
|
1890
1890
|
return new OneTimeBinding(expression, policy);
|
|
1891
1891
|
}
|
|
1892
1892
|
|
|
1893
|
+
/**
|
|
1894
|
+
* Normalizes the input value into a binding.
|
|
1895
|
+
* @param value - The value to create the default binding for.
|
|
1896
|
+
* @returns A binding configuration for the provided value.
|
|
1897
|
+
* @public
|
|
1898
|
+
*/
|
|
1899
|
+
function normalizeBinding$1(value) {
|
|
1900
|
+
return isFunction(value)
|
|
1901
|
+
? oneWay(value)
|
|
1902
|
+
: value instanceof Binding
|
|
1903
|
+
? value
|
|
1904
|
+
: oneTime(() => value);
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1893
1907
|
let DefaultStyleStrategy;
|
|
1894
1908
|
function reduceStyles(styles) {
|
|
1895
1909
|
return styles
|
|
@@ -3000,6 +3014,9 @@ const Compiler = {
|
|
|
3000
3014
|
else {
|
|
3001
3015
|
template = html;
|
|
3002
3016
|
}
|
|
3017
|
+
if (!template.content.firstChild && !template.content.lastChild) {
|
|
3018
|
+
template.content.appendChild(document.createComment(""));
|
|
3019
|
+
}
|
|
3003
3020
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1111864
|
|
3004
3021
|
const fragment = document.adoptNode(template.content);
|
|
3005
3022
|
const context = new CompilationContext(fragment, factories, policy);
|
|
@@ -3261,33 +3278,26 @@ HTMLDirective.define(RefDirective);
|
|
|
3261
3278
|
*/
|
|
3262
3279
|
const ref = (propertyName) => new RefDirective(propertyName);
|
|
3263
3280
|
|
|
3281
|
+
const noTemplate = () => null;
|
|
3282
|
+
function normalizeBinding(value) {
|
|
3283
|
+
return value === undefined ? noTemplate : isFunction(value) ? value : () => value;
|
|
3284
|
+
}
|
|
3264
3285
|
/**
|
|
3265
3286
|
* A directive that enables basic conditional rendering in a template.
|
|
3266
3287
|
* @param condition - The condition to test for rendering.
|
|
3267
3288
|
* @param templateOrTemplateBinding - The template or a binding that gets
|
|
3268
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.
|
|
3269
3292
|
* @public
|
|
3270
3293
|
*/
|
|
3271
|
-
function when(condition, templateOrTemplateBinding) {
|
|
3294
|
+
function when(condition, templateOrTemplateBinding, elseTemplateOrTemplateBinding) {
|
|
3272
3295
|
const dataBinding = isFunction(condition) ? condition : () => condition;
|
|
3273
|
-
const templateBinding =
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
/**
|
|
3280
|
-
* Normalizes the input value into a binding.
|
|
3281
|
-
* @param value - The value to create the default binding for.
|
|
3282
|
-
* @returns A binding configuration for the provided value.
|
|
3283
|
-
* @public
|
|
3284
|
-
*/
|
|
3285
|
-
function normalizeBinding(value) {
|
|
3286
|
-
return isFunction(value)
|
|
3287
|
-
? oneWay(value)
|
|
3288
|
-
: value instanceof Binding
|
|
3289
|
-
? value
|
|
3290
|
-
: oneTime(() => value);
|
|
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, 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 };
|