@microsoft/fast-element 2.0.0-beta.13 → 2.0.0-beta.15
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 +42 -0
- package/CHANGELOG.md +19 -1
- package/dist/dts/components/element-controller.d.ts +15 -3
- package/dist/dts/components/hydration.d.ts +14 -0
- package/dist/dts/components/install-hydration.d.ts +1 -0
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/templating/binding.d.ts +7 -13
- package/dist/dts/testing/fakes.d.ts +1 -1
- package/dist/dts/utilities.d.ts +14 -0
- package/dist/esm/components/element-controller.js +30 -22
- package/dist/esm/components/hydration.js +35 -0
- package/dist/esm/components/install-hydration.js +2 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/templating/binding.js +33 -40
- package/dist/esm/testing/fakes.js +1 -1
- package/dist/esm/utilities.js +27 -0
- package/dist/fast-element.api.json +134 -9
- package/dist/fast-element.d.ts +20 -10
- package/dist/fast-element.debug.js +63 -62
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +63 -62
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +21 -14
- package/docs/api-report.md +11 -10
- package/package.json +11 -2
|
@@ -1442,7 +1442,7 @@
|
|
|
1442
1442
|
{
|
|
1443
1443
|
"kind": "Function",
|
|
1444
1444
|
"canonicalReference": "@microsoft/fast-element!bind:function(1)",
|
|
1445
|
-
"docComment": "/**\n * Creates an standard binding.\n *\n * @param
|
|
1445
|
+
"docComment": "/**\n * Creates an standard binding.\n *\n * @param expression - The binding to refresh when changed.\n *\n * @param isVolatile - Indicates whether the binding is volatile or not.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
|
|
1446
1446
|
"excerptTokens": [
|
|
1447
1447
|
{
|
|
1448
1448
|
"kind": "Content",
|
|
@@ -1454,7 +1454,7 @@
|
|
|
1454
1454
|
},
|
|
1455
1455
|
{
|
|
1456
1456
|
"kind": "Content",
|
|
1457
|
-
"text": ">(
|
|
1457
|
+
"text": ">(expression: "
|
|
1458
1458
|
},
|
|
1459
1459
|
{
|
|
1460
1460
|
"kind": "Reference",
|
|
@@ -1499,7 +1499,7 @@
|
|
|
1499
1499
|
"overloadIndex": 1,
|
|
1500
1500
|
"parameters": [
|
|
1501
1501
|
{
|
|
1502
|
-
"parameterName": "
|
|
1502
|
+
"parameterName": "expression",
|
|
1503
1503
|
"parameterTypeTokenRange": {
|
|
1504
1504
|
"startIndex": 3,
|
|
1505
1505
|
"endIndex": 5
|
|
@@ -4267,6 +4267,53 @@
|
|
|
4267
4267
|
],
|
|
4268
4268
|
"name": "removeStyles"
|
|
4269
4269
|
},
|
|
4270
|
+
{
|
|
4271
|
+
"kind": "Method",
|
|
4272
|
+
"canonicalReference": "@microsoft/fast-element!ElementController.setStrategy:member(1)",
|
|
4273
|
+
"docComment": "/**\n * Sets the strategy that ElementController.forCustomElement uses to construct ElementController instances for an element.\n *\n * @param strategy - The strategy to use.\n */\n",
|
|
4274
|
+
"excerptTokens": [
|
|
4275
|
+
{
|
|
4276
|
+
"kind": "Content",
|
|
4277
|
+
"text": "static setStrategy(strategy: "
|
|
4278
|
+
},
|
|
4279
|
+
{
|
|
4280
|
+
"kind": "Reference",
|
|
4281
|
+
"text": "ElementControllerStrategy",
|
|
4282
|
+
"canonicalReference": "@microsoft/fast-element!ElementControllerStrategy:interface"
|
|
4283
|
+
},
|
|
4284
|
+
{
|
|
4285
|
+
"kind": "Content",
|
|
4286
|
+
"text": "): "
|
|
4287
|
+
},
|
|
4288
|
+
{
|
|
4289
|
+
"kind": "Content",
|
|
4290
|
+
"text": "void"
|
|
4291
|
+
},
|
|
4292
|
+
{
|
|
4293
|
+
"kind": "Content",
|
|
4294
|
+
"text": ";"
|
|
4295
|
+
}
|
|
4296
|
+
],
|
|
4297
|
+
"isOptional": false,
|
|
4298
|
+
"isStatic": true,
|
|
4299
|
+
"returnTypeTokenRange": {
|
|
4300
|
+
"startIndex": 3,
|
|
4301
|
+
"endIndex": 4
|
|
4302
|
+
},
|
|
4303
|
+
"releaseTag": "Public",
|
|
4304
|
+
"overloadIndex": 1,
|
|
4305
|
+
"parameters": [
|
|
4306
|
+
{
|
|
4307
|
+
"parameterName": "strategy",
|
|
4308
|
+
"parameterTypeTokenRange": {
|
|
4309
|
+
"startIndex": 1,
|
|
4310
|
+
"endIndex": 2
|
|
4311
|
+
},
|
|
4312
|
+
"isOptional": false
|
|
4313
|
+
}
|
|
4314
|
+
],
|
|
4315
|
+
"name": "setStrategy"
|
|
4316
|
+
},
|
|
4270
4317
|
{
|
|
4271
4318
|
"kind": "Property",
|
|
4272
4319
|
"canonicalReference": "@microsoft/fast-element!ElementController#source:member",
|
|
@@ -4383,6 +4430,84 @@
|
|
|
4383
4430
|
}
|
|
4384
4431
|
]
|
|
4385
4432
|
},
|
|
4433
|
+
{
|
|
4434
|
+
"kind": "Interface",
|
|
4435
|
+
"canonicalReference": "@microsoft/fast-element!ElementControllerStrategy:interface",
|
|
4436
|
+
"docComment": "/**\n * A type that instantiates an ElementController\n *\n * @public\n */\n",
|
|
4437
|
+
"excerptTokens": [
|
|
4438
|
+
{
|
|
4439
|
+
"kind": "Content",
|
|
4440
|
+
"text": "export interface ElementControllerStrategy "
|
|
4441
|
+
}
|
|
4442
|
+
],
|
|
4443
|
+
"releaseTag": "Public",
|
|
4444
|
+
"name": "ElementControllerStrategy",
|
|
4445
|
+
"members": [
|
|
4446
|
+
{
|
|
4447
|
+
"kind": "ConstructSignature",
|
|
4448
|
+
"canonicalReference": "@microsoft/fast-element!ElementControllerStrategy:new(1)",
|
|
4449
|
+
"docComment": "",
|
|
4450
|
+
"excerptTokens": [
|
|
4451
|
+
{
|
|
4452
|
+
"kind": "Content",
|
|
4453
|
+
"text": "new (element: "
|
|
4454
|
+
},
|
|
4455
|
+
{
|
|
4456
|
+
"kind": "Reference",
|
|
4457
|
+
"text": "HTMLElement",
|
|
4458
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
4459
|
+
},
|
|
4460
|
+
{
|
|
4461
|
+
"kind": "Content",
|
|
4462
|
+
"text": ", definition: "
|
|
4463
|
+
},
|
|
4464
|
+
{
|
|
4465
|
+
"kind": "Reference",
|
|
4466
|
+
"text": "FASTElementDefinition",
|
|
4467
|
+
"canonicalReference": "@microsoft/fast-element!FASTElementDefinition:class"
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
"kind": "Content",
|
|
4471
|
+
"text": "): "
|
|
4472
|
+
},
|
|
4473
|
+
{
|
|
4474
|
+
"kind": "Reference",
|
|
4475
|
+
"text": "ElementController",
|
|
4476
|
+
"canonicalReference": "@microsoft/fast-element!ElementController:class"
|
|
4477
|
+
},
|
|
4478
|
+
{
|
|
4479
|
+
"kind": "Content",
|
|
4480
|
+
"text": ";"
|
|
4481
|
+
}
|
|
4482
|
+
],
|
|
4483
|
+
"returnTypeTokenRange": {
|
|
4484
|
+
"startIndex": 5,
|
|
4485
|
+
"endIndex": 6
|
|
4486
|
+
},
|
|
4487
|
+
"releaseTag": "Public",
|
|
4488
|
+
"overloadIndex": 1,
|
|
4489
|
+
"parameters": [
|
|
4490
|
+
{
|
|
4491
|
+
"parameterName": "element",
|
|
4492
|
+
"parameterTypeTokenRange": {
|
|
4493
|
+
"startIndex": 1,
|
|
4494
|
+
"endIndex": 2
|
|
4495
|
+
},
|
|
4496
|
+
"isOptional": false
|
|
4497
|
+
},
|
|
4498
|
+
{
|
|
4499
|
+
"parameterName": "definition",
|
|
4500
|
+
"parameterTypeTokenRange": {
|
|
4501
|
+
"startIndex": 3,
|
|
4502
|
+
"endIndex": 4
|
|
4503
|
+
},
|
|
4504
|
+
"isOptional": false
|
|
4505
|
+
}
|
|
4506
|
+
]
|
|
4507
|
+
}
|
|
4508
|
+
],
|
|
4509
|
+
"extendsTokenRanges": []
|
|
4510
|
+
},
|
|
4386
4511
|
{
|
|
4387
4512
|
"kind": "Variable",
|
|
4388
4513
|
"canonicalReference": "@microsoft/fast-element!elements:var",
|
|
@@ -10141,7 +10266,7 @@
|
|
|
10141
10266
|
{
|
|
10142
10267
|
"kind": "Function",
|
|
10143
10268
|
"canonicalReference": "@microsoft/fast-element!listener:function(1)",
|
|
10144
|
-
"docComment": "/**\n * Creates an event listener binding.\n *\n * @param
|
|
10269
|
+
"docComment": "/**\n * Creates an event listener binding.\n *\n * @param expression - The binding to invoke when the event is raised.\n *\n * @param options - Event listener options.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
|
|
10145
10270
|
"excerptTokens": [
|
|
10146
10271
|
{
|
|
10147
10272
|
"kind": "Content",
|
|
@@ -10153,7 +10278,7 @@
|
|
|
10153
10278
|
},
|
|
10154
10279
|
{
|
|
10155
10280
|
"kind": "Content",
|
|
10156
|
-
"text": ">(
|
|
10281
|
+
"text": ">(expression: "
|
|
10157
10282
|
},
|
|
10158
10283
|
{
|
|
10159
10284
|
"kind": "Reference",
|
|
@@ -10199,7 +10324,7 @@
|
|
|
10199
10324
|
"overloadIndex": 1,
|
|
10200
10325
|
"parameters": [
|
|
10201
10326
|
{
|
|
10202
|
-
"parameterName": "
|
|
10327
|
+
"parameterName": "expression",
|
|
10203
10328
|
"parameterTypeTokenRange": {
|
|
10204
10329
|
"startIndex": 3,
|
|
10205
10330
|
"endIndex": 5
|
|
@@ -11397,7 +11522,7 @@
|
|
|
11397
11522
|
{
|
|
11398
11523
|
"kind": "Function",
|
|
11399
11524
|
"canonicalReference": "@microsoft/fast-element!oneTime:function(1)",
|
|
11400
|
-
"docComment": "/**\n * Creates a one time binding\n *\n * @param
|
|
11525
|
+
"docComment": "/**\n * Creates a one time binding\n *\n * @param expression - The binding to refresh when signaled.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
|
|
11401
11526
|
"excerptTokens": [
|
|
11402
11527
|
{
|
|
11403
11528
|
"kind": "Content",
|
|
@@ -11409,7 +11534,7 @@
|
|
|
11409
11534
|
},
|
|
11410
11535
|
{
|
|
11411
11536
|
"kind": "Content",
|
|
11412
|
-
"text": ">(
|
|
11537
|
+
"text": ">(expression: "
|
|
11413
11538
|
},
|
|
11414
11539
|
{
|
|
11415
11540
|
"kind": "Reference",
|
|
@@ -11446,7 +11571,7 @@
|
|
|
11446
11571
|
"overloadIndex": 1,
|
|
11447
11572
|
"parameters": [
|
|
11448
11573
|
{
|
|
11449
|
-
"parameterName": "
|
|
11574
|
+
"parameterName": "expression",
|
|
11450
11575
|
"parameterTypeTokenRange": {
|
|
11451
11576
|
"startIndex": 3,
|
|
11452
11577
|
"endIndex": 5
|
package/dist/fast-element.d.ts
CHANGED
|
@@ -258,12 +258,12 @@ export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "f
|
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
* Creates an standard binding.
|
|
261
|
-
* @param
|
|
261
|
+
* @param expression - The binding to refresh when changed.
|
|
262
262
|
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
263
263
|
* @returns A binding configuration.
|
|
264
264
|
* @public
|
|
265
265
|
*/
|
|
266
|
-
export declare function bind<T = any>(
|
|
266
|
+
export declare function bind<T = any>(expression: Expression<T>, isVolatile?: boolean): Binding<T>;
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* Captures a binding expression along with related information and capabilities.
|
|
@@ -755,7 +755,6 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
755
755
|
* Only emits events if connected.
|
|
756
756
|
*/
|
|
757
757
|
emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
|
|
758
|
-
private finishInitialization;
|
|
759
758
|
private renderTemplate;
|
|
760
759
|
/**
|
|
761
760
|
* Locates or creates a controller for the specified element.
|
|
@@ -766,6 +765,20 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
|
|
|
766
765
|
* decorator or a call to `FASTElement.define`.
|
|
767
766
|
*/
|
|
768
767
|
static forCustomElement(element: HTMLElement): ElementController;
|
|
768
|
+
/**
|
|
769
|
+
* Sets the strategy that ElementController.forCustomElement uses to construct
|
|
770
|
+
* ElementController instances for an element.
|
|
771
|
+
* @param strategy - The strategy to use.
|
|
772
|
+
*/
|
|
773
|
+
static setStrategy(strategy: ElementControllerStrategy): void;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* A type that instantiates an ElementController
|
|
778
|
+
* @public
|
|
779
|
+
*/
|
|
780
|
+
export declare interface ElementControllerStrategy {
|
|
781
|
+
new (element: HTMLElement, definition: FASTElementDefinition): ElementController;
|
|
769
782
|
}
|
|
770
783
|
|
|
771
784
|
/**
|
|
@@ -1295,10 +1308,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
|
|
|
1295
1308
|
* Creates a behavior.
|
|
1296
1309
|
*/
|
|
1297
1310
|
createBehavior(): ViewBehavior;
|
|
1298
|
-
/* Excluded from this release type: bindDefault */
|
|
1299
1311
|
/* Excluded from this release type: bind */
|
|
1300
|
-
/* Excluded from this release type: bindContent */
|
|
1301
|
-
/* Excluded from this release type: bindEvent */
|
|
1302
1312
|
/* Excluded from this release type: unbind */
|
|
1303
1313
|
/* Excluded from this release type: handleEvent */
|
|
1304
1314
|
/* Excluded from this release type: handleChange */
|
|
@@ -1524,12 +1534,12 @@ export declare function lengthOf<T>(array: readonly T[]): number;
|
|
|
1524
1534
|
|
|
1525
1535
|
/**
|
|
1526
1536
|
* Creates an event listener binding.
|
|
1527
|
-
* @param
|
|
1537
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
1528
1538
|
* @param options - Event listener options.
|
|
1529
1539
|
* @returns A binding configuration.
|
|
1530
1540
|
* @public
|
|
1531
1541
|
*/
|
|
1532
|
-
export declare function listener<T = any>(
|
|
1542
|
+
export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
|
|
1533
1543
|
|
|
1534
1544
|
/**
|
|
1535
1545
|
* Common APIs related to markup generation.
|
|
@@ -1776,11 +1786,11 @@ export declare interface ObservationRecord {
|
|
|
1776
1786
|
|
|
1777
1787
|
/**
|
|
1778
1788
|
* Creates a one time binding
|
|
1779
|
-
* @param
|
|
1789
|
+
* @param expression - The binding to refresh when signaled.
|
|
1780
1790
|
* @returns A binding configuration.
|
|
1781
1791
|
* @public
|
|
1782
1792
|
*/
|
|
1783
|
-
export declare function oneTime<T = any>(
|
|
1793
|
+
export declare function oneTime<T = any>(expression: Expression<T>): Binding<T>;
|
|
1784
1794
|
|
|
1785
1795
|
/**
|
|
1786
1796
|
* Common APIs related to content parsing.
|
|
@@ -1963,9 +1963,9 @@ function updateContent(target, aspect, value, controller) {
|
|
|
1963
1963
|
function updateTokenList(target, aspect, value) {
|
|
1964
1964
|
var _a;
|
|
1965
1965
|
const lookup = `${this.id}-t`;
|
|
1966
|
-
const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = {
|
|
1967
|
-
const
|
|
1968
|
-
let
|
|
1966
|
+
const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = { v: 0, cv: Object.create(null) });
|
|
1967
|
+
const classVersions = state.cv;
|
|
1968
|
+
let version = state.v;
|
|
1969
1969
|
const tokenList = target[aspect];
|
|
1970
1970
|
// Add the classes, tracking the version at which they were added.
|
|
1971
1971
|
if (value !== null && value !== undefined && value.length) {
|
|
@@ -1975,19 +1975,19 @@ function updateTokenList(target, aspect, value) {
|
|
|
1975
1975
|
if (currentName === "") {
|
|
1976
1976
|
continue;
|
|
1977
1977
|
}
|
|
1978
|
-
|
|
1978
|
+
classVersions[currentName] = version;
|
|
1979
1979
|
tokenList.add(currentName);
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
|
-
state.v =
|
|
1982
|
+
state.v = version + 1;
|
|
1983
1983
|
// If this is the first call to add classes, there's no need to remove old ones.
|
|
1984
|
-
if (
|
|
1984
|
+
if (version === 0) {
|
|
1985
1985
|
return;
|
|
1986
1986
|
}
|
|
1987
1987
|
// Remove classes from the previous version.
|
|
1988
|
-
|
|
1989
|
-
for (const name in
|
|
1990
|
-
if (
|
|
1988
|
+
version -= 1;
|
|
1989
|
+
for (const name in classVersions) {
|
|
1990
|
+
if (classVersions[name] === version) {
|
|
1991
1991
|
tokenList.remove(name);
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
@@ -2014,8 +2014,6 @@ class HTMLBindingDirective {
|
|
|
2014
2014
|
* The type of aspect to target.
|
|
2015
2015
|
*/
|
|
2016
2016
|
this.aspectType = Aspect.content;
|
|
2017
|
-
/** @internal */
|
|
2018
|
-
this.bind = this.bindDefault;
|
|
2019
2017
|
this.data = `${this.id}-d`;
|
|
2020
2018
|
}
|
|
2021
2019
|
/**
|
|
@@ -2044,14 +2042,12 @@ class HTMLBindingDirective {
|
|
|
2044
2042
|
this.updateTarget = setProperty;
|
|
2045
2043
|
break;
|
|
2046
2044
|
case 4:
|
|
2047
|
-
this.bind = this.bindContent;
|
|
2048
2045
|
this.updateTarget = updateContent;
|
|
2049
2046
|
break;
|
|
2050
2047
|
case 5:
|
|
2051
2048
|
this.updateTarget = updateTokenList;
|
|
2052
2049
|
break;
|
|
2053
2050
|
case 6:
|
|
2054
|
-
this.bind = this.bindEvent;
|
|
2055
2051
|
this.updateTarget = eventTarget;
|
|
2056
2052
|
break;
|
|
2057
2053
|
default:
|
|
@@ -2061,29 +2057,26 @@ class HTMLBindingDirective {
|
|
|
2061
2057
|
return this;
|
|
2062
2058
|
}
|
|
2063
2059
|
/** @internal */
|
|
2064
|
-
|
|
2060
|
+
bind(controller) {
|
|
2065
2061
|
var _a;
|
|
2066
2062
|
const target = controller.targets[this.nodeId];
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2063
|
+
switch (this.updateTarget) {
|
|
2064
|
+
case eventTarget:
|
|
2065
|
+
target[this.data] = controller;
|
|
2066
|
+
target.addEventListener(this.targetAspect, this, this.dataBinding.options);
|
|
2067
|
+
break;
|
|
2068
|
+
case updateContent:
|
|
2069
|
+
controller.onUnbind(this);
|
|
2070
|
+
// intentional fall through
|
|
2071
|
+
default:
|
|
2072
|
+
const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
|
|
2073
|
+
observer.target = target;
|
|
2074
|
+
observer.controller = controller;
|
|
2075
|
+
this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
|
|
2076
|
+
break;
|
|
2073
2077
|
}
|
|
2074
2078
|
}
|
|
2075
2079
|
/** @internal */
|
|
2076
|
-
bindContent(controller) {
|
|
2077
|
-
this.bindDefault(controller);
|
|
2078
|
-
controller.onUnbind(this);
|
|
2079
|
-
}
|
|
2080
|
-
/** @internal */
|
|
2081
|
-
bindEvent(controller) {
|
|
2082
|
-
const target = controller.targets[this.nodeId];
|
|
2083
|
-
target[this.data] = controller;
|
|
2084
|
-
target.addEventListener(this.targetAspect, this, this.dataBinding.options);
|
|
2085
|
-
}
|
|
2086
|
-
/** @internal */
|
|
2087
2080
|
unbind(controller) {
|
|
2088
2081
|
const target = controller.targets[this.nodeId];
|
|
2089
2082
|
const view = target.$fastView;
|
|
@@ -2114,32 +2107,32 @@ class HTMLBindingDirective {
|
|
|
2114
2107
|
HTMLDirective.define(HTMLBindingDirective, { aspected: true });
|
|
2115
2108
|
/**
|
|
2116
2109
|
* Creates an standard binding.
|
|
2117
|
-
* @param
|
|
2110
|
+
* @param expression - The binding to refresh when changed.
|
|
2118
2111
|
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
2119
2112
|
* @returns A binding configuration.
|
|
2120
2113
|
* @public
|
|
2121
2114
|
*/
|
|
2122
|
-
function bind(
|
|
2123
|
-
return new OnChangeBinding(
|
|
2115
|
+
function bind(expression, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
2116
|
+
return new OnChangeBinding(expression, isVolatile);
|
|
2124
2117
|
}
|
|
2125
2118
|
/**
|
|
2126
2119
|
* Creates a one time binding
|
|
2127
|
-
* @param
|
|
2120
|
+
* @param expression - The binding to refresh when signaled.
|
|
2128
2121
|
* @returns A binding configuration.
|
|
2129
2122
|
* @public
|
|
2130
2123
|
*/
|
|
2131
|
-
function oneTime(
|
|
2132
|
-
return new OneTimeBinding(
|
|
2124
|
+
function oneTime(expression) {
|
|
2125
|
+
return new OneTimeBinding(expression);
|
|
2133
2126
|
}
|
|
2134
2127
|
/**
|
|
2135
2128
|
* Creates an event listener binding.
|
|
2136
|
-
* @param
|
|
2129
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
2137
2130
|
* @param options - Event listener options.
|
|
2138
2131
|
* @returns A binding configuration.
|
|
2139
2132
|
* @public
|
|
2140
2133
|
*/
|
|
2141
|
-
function listener(
|
|
2142
|
-
const config = new OnChangeBinding(
|
|
2134
|
+
function listener(expression, options) {
|
|
2135
|
+
const config = new OnChangeBinding(expression, false);
|
|
2143
2136
|
config.options = options;
|
|
2144
2137
|
return config;
|
|
2145
2138
|
}
|
|
@@ -3581,6 +3574,7 @@ function getShadowRoot(element) {
|
|
|
3581
3574
|
var _a, _b;
|
|
3582
3575
|
return (_b = (_a = element.shadowRoot) !== null && _a !== void 0 ? _a : shadowRoots.get(element)) !== null && _b !== void 0 ? _b : null;
|
|
3583
3576
|
}
|
|
3577
|
+
let elementControllerStrategy;
|
|
3584
3578
|
/**
|
|
3585
3579
|
* Controls the lifecycle and rendering of a `FASTElement`.
|
|
3586
3580
|
* @public
|
|
@@ -3822,11 +3816,16 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3822
3816
|
if (this._isConnected) {
|
|
3823
3817
|
return;
|
|
3824
3818
|
}
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3819
|
+
// If we have any observables that were bound, re-apply their values.
|
|
3820
|
+
if (this.boundObservables !== null) {
|
|
3821
|
+
const element = this.source;
|
|
3822
|
+
const boundObservables = this.boundObservables;
|
|
3823
|
+
const propertyNames = Object.keys(boundObservables);
|
|
3824
|
+
for (let i = 0, ii = propertyNames.length; i < ii; ++i) {
|
|
3825
|
+
const propertyName = propertyNames[i];
|
|
3826
|
+
element[propertyName] = boundObservables[propertyName];
|
|
3827
|
+
}
|
|
3828
|
+
this.boundObservables = null;
|
|
3830
3829
|
}
|
|
3831
3830
|
const behaviors = this.behaviors;
|
|
3832
3831
|
if (behaviors !== null) {
|
|
@@ -3834,6 +3833,14 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3834
3833
|
key.connectedCallback && key.connectedCallback(this);
|
|
3835
3834
|
}
|
|
3836
3835
|
}
|
|
3836
|
+
if (this.needsInitialization) {
|
|
3837
|
+
this.renderTemplate(this.template);
|
|
3838
|
+
this.addStyles(this.mainStyles);
|
|
3839
|
+
this.needsInitialization = false;
|
|
3840
|
+
}
|
|
3841
|
+
else if (this.view !== null) {
|
|
3842
|
+
this.view.bind(this.source);
|
|
3843
|
+
}
|
|
3837
3844
|
this.setIsConnected(true);
|
|
3838
3845
|
}
|
|
3839
3846
|
/**
|
|
@@ -3880,22 +3887,6 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3880
3887
|
}
|
|
3881
3888
|
return false;
|
|
3882
3889
|
}
|
|
3883
|
-
finishInitialization() {
|
|
3884
|
-
const element = this.source;
|
|
3885
|
-
const boundObservables = this.boundObservables;
|
|
3886
|
-
// If we have any observables that were bound, re-apply their values.
|
|
3887
|
-
if (boundObservables !== null) {
|
|
3888
|
-
const propertyNames = Object.keys(boundObservables);
|
|
3889
|
-
for (let i = 0, ii = propertyNames.length; i < ii; ++i) {
|
|
3890
|
-
const propertyName = propertyNames[i];
|
|
3891
|
-
element[propertyName] = boundObservables[propertyName];
|
|
3892
|
-
}
|
|
3893
|
-
this.boundObservables = null;
|
|
3894
|
-
}
|
|
3895
|
-
this.renderTemplate(this.template);
|
|
3896
|
-
this.addStyles(this.mainStyles);
|
|
3897
|
-
this.needsInitialization = false;
|
|
3898
|
-
}
|
|
3899
3890
|
renderTemplate(template) {
|
|
3900
3891
|
var _a;
|
|
3901
3892
|
// When getting the host to render to, we start by looking
|
|
@@ -3939,9 +3930,19 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3939
3930
|
if (definition === void 0) {
|
|
3940
3931
|
throw FAST.error(1401 /* Message.missingElementDefinition */);
|
|
3941
3932
|
}
|
|
3942
|
-
return (element.$fastController = new
|
|
3933
|
+
return (element.$fastController = new elementControllerStrategy(element, definition));
|
|
3934
|
+
}
|
|
3935
|
+
/**
|
|
3936
|
+
* Sets the strategy that ElementController.forCustomElement uses to construct
|
|
3937
|
+
* ElementController instances for an element.
|
|
3938
|
+
* @param strategy - The strategy to use.
|
|
3939
|
+
*/
|
|
3940
|
+
static setStrategy(strategy) {
|
|
3941
|
+
elementControllerStrategy = strategy;
|
|
3943
3942
|
}
|
|
3944
3943
|
}
|
|
3944
|
+
// Set default strategy for ElementController
|
|
3945
|
+
ElementController.setStrategy(ElementController);
|
|
3945
3946
|
/**
|
|
3946
3947
|
* Converts a styleTarget into the operative target. When the provided target is an Element
|
|
3947
3948
|
* that is a FASTElement, the function will return the ShadowRoot for that element. Otherwise,
|