@microsoft/fast-element 2.0.0-beta.21 → 2.0.0-beta.22
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 +33 -0
- package/CHANGELOG.md +12 -1
- package/dist/dts/binding/binding.d.ts +49 -0
- package/dist/dts/binding/normalize.d.ts +9 -0
- package/dist/dts/binding/one-time.d.ts +11 -0
- package/dist/dts/binding/one-way.d.ts +20 -0
- package/dist/dts/{templating/binding-signal.d.ts → binding/signal.d.ts} +1 -1
- package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +3 -4
- package/dist/dts/components/element-controller.d.ts +20 -5
- package/dist/dts/context.d.ts +20 -7
- package/dist/dts/index.d.ts +6 -2
- package/dist/dts/interfaces.d.ts +4 -4
- package/dist/dts/metadata.d.ts +1 -0
- package/dist/dts/platform.d.ts +9 -1
- package/dist/dts/styles/css-binding-directive.d.ts +60 -0
- package/dist/dts/styles/css.d.ts +9 -2
- package/dist/dts/styles/host.d.ts +2 -5
- package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +3 -34
- package/dist/dts/templating/html-directive.d.ts +3 -35
- package/dist/dts/templating/render.d.ts +19 -5
- package/dist/dts/templating/repeat.d.ts +3 -2
- package/dist/dts/templating/template.d.ts +2 -6
- package/dist/dts/templating/view.d.ts +16 -6
- package/dist/dts/testing/fakes.d.ts +2 -1
- package/dist/esm/binding/binding.js +18 -0
- package/dist/esm/binding/normalize.js +17 -0
- package/dist/esm/binding/one-time.js +21 -0
- package/dist/esm/binding/one-way.js +30 -0
- package/dist/esm/{templating/binding-signal.js → binding/signal.js} +5 -8
- package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +11 -15
- package/dist/esm/components/element-controller.js +33 -8
- package/dist/esm/context.js +22 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/interfaces.js +3 -3
- package/dist/esm/metadata.js +3 -1
- package/dist/esm/observation/observable.js +3 -6
- package/dist/esm/platform.js +9 -0
- package/dist/esm/styles/css-binding-directive.js +76 -0
- package/dist/esm/styles/css.js +14 -2
- package/dist/esm/templating/compiler.js +2 -1
- package/dist/esm/templating/{binding.js → html-binding-directive.js} +3 -70
- package/dist/esm/templating/html-directive.js +2 -25
- package/dist/esm/templating/render.js +25 -12
- package/dist/esm/templating/repeat.js +3 -3
- package/dist/esm/templating/template.js +9 -10
- package/dist/esm/templating/view.js +2 -6
- package/dist/esm/testing/fakes.js +1 -1
- package/dist/fast-element.api.json +1127 -342
- package/dist/fast-element.d.ts +125 -41
- package/dist/fast-element.debug.js +217 -117
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +217 -117
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +132 -80
- package/docs/api-report.md +52 -51
- package/package.json +5 -5
|
@@ -109,17 +109,17 @@ switch (kernelMode) {
|
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Determines whether or not an object is a function.
|
|
112
|
-
* @
|
|
112
|
+
* @public
|
|
113
113
|
*/
|
|
114
114
|
const isFunction = (object) => typeof object === "function";
|
|
115
115
|
/**
|
|
116
116
|
* Determines whether or not an object is a string.
|
|
117
|
-
* @
|
|
117
|
+
* @public
|
|
118
118
|
*/
|
|
119
119
|
const isString = (object) => typeof object === "string";
|
|
120
120
|
/**
|
|
121
121
|
* A function which does nothing.
|
|
122
|
-
* @
|
|
122
|
+
* @public
|
|
123
123
|
*/
|
|
124
124
|
const noop = () => void 0;
|
|
125
125
|
|
|
@@ -238,6 +238,14 @@ function createMetadataLocator() {
|
|
|
238
238
|
return metadata;
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Makes a type noop for JSON serialization.
|
|
243
|
+
* @param type - The type to make noop for JSON serialization.
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
function makeSerializationNoop(type) {
|
|
247
|
+
type.prototype.toJSON = noop;
|
|
248
|
+
}
|
|
241
249
|
|
|
242
250
|
/**
|
|
243
251
|
* The type of HTML aspect to target.
|
|
@@ -989,10 +997,6 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
989
997
|
this.propertyName = void 0;
|
|
990
998
|
this.notifier = void 0;
|
|
991
999
|
this.next = void 0;
|
|
992
|
-
/**
|
|
993
|
-
* Opts out of JSON stringification.
|
|
994
|
-
*/
|
|
995
|
-
this.toJSON = noop;
|
|
996
1000
|
}
|
|
997
1001
|
setMode(isAsync) {
|
|
998
1002
|
this.isAsync = this.needsQueue = isAsync;
|
|
@@ -1094,6 +1098,7 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
1094
1098
|
}
|
|
1095
1099
|
}
|
|
1096
1100
|
}
|
|
1101
|
+
makeSerializationNoop(ExpressionNotifierImplementation);
|
|
1097
1102
|
return Object.freeze({
|
|
1098
1103
|
/**
|
|
1099
1104
|
* @internal
|
|
@@ -1817,6 +1822,74 @@ function lengthOf(array) {
|
|
|
1817
1822
|
return array.length;
|
|
1818
1823
|
}
|
|
1819
1824
|
|
|
1825
|
+
/**
|
|
1826
|
+
* Captures a binding expression along with related information and capabilities.
|
|
1827
|
+
*
|
|
1828
|
+
* @public
|
|
1829
|
+
*/
|
|
1830
|
+
class Binding {
|
|
1831
|
+
/**
|
|
1832
|
+
* Creates a binding.
|
|
1833
|
+
* @param evaluate - Evaluates the binding.
|
|
1834
|
+
* @param policy - The security policy to associate with this binding.
|
|
1835
|
+
* @param isVolatile - Indicates whether the binding is volatile.
|
|
1836
|
+
*/
|
|
1837
|
+
constructor(evaluate, policy, isVolatile = false) {
|
|
1838
|
+
this.evaluate = evaluate;
|
|
1839
|
+
this.policy = policy;
|
|
1840
|
+
this.isVolatile = isVolatile;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
class OneWayBinding extends Binding {
|
|
1845
|
+
createObserver(subscriber) {
|
|
1846
|
+
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Creates an standard binding.
|
|
1851
|
+
* @param expression - The binding to refresh when changed.
|
|
1852
|
+
* @param policy - The security policy to associate with th binding.
|
|
1853
|
+
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
1854
|
+
* @returns A binding configuration.
|
|
1855
|
+
* @public
|
|
1856
|
+
*/
|
|
1857
|
+
function oneWay(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
1858
|
+
return new OneWayBinding(expression, policy, isVolatile);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Creates an event listener binding.
|
|
1862
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
1863
|
+
* @param options - Event listener options.
|
|
1864
|
+
* @returns A binding configuration.
|
|
1865
|
+
* @public
|
|
1866
|
+
*/
|
|
1867
|
+
function listener(expression, options) {
|
|
1868
|
+
const config = new OneWayBinding(expression);
|
|
1869
|
+
config.options = options;
|
|
1870
|
+
return config;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
class OneTimeBinding extends Binding {
|
|
1874
|
+
createObserver() {
|
|
1875
|
+
return this;
|
|
1876
|
+
}
|
|
1877
|
+
bind(controller) {
|
|
1878
|
+
return this.evaluate(controller.source, controller.context);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
makeSerializationNoop(OneTimeBinding);
|
|
1882
|
+
/**
|
|
1883
|
+
* Creates a one time binding
|
|
1884
|
+
* @param expression - The binding to refresh when signaled.
|
|
1885
|
+
* @param policy - The security policy to associate with th binding.
|
|
1886
|
+
* @returns A binding configuration.
|
|
1887
|
+
* @public
|
|
1888
|
+
*/
|
|
1889
|
+
function oneTime(expression, policy) {
|
|
1890
|
+
return new OneTimeBinding(expression, policy);
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1820
1893
|
let DefaultStyleStrategy;
|
|
1821
1894
|
function reduceStyles(styles) {
|
|
1822
1895
|
return styles
|
|
@@ -1945,6 +2018,85 @@ function cssDirective() {
|
|
|
1945
2018
|
};
|
|
1946
2019
|
}
|
|
1947
2020
|
|
|
2021
|
+
function handleChange(directive, controller, observer) {
|
|
2022
|
+
controller.source.style.setProperty(directive.targetAspect, observer.bind(controller));
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Enables bindings in CSS.
|
|
2026
|
+
*
|
|
2027
|
+
* @public
|
|
2028
|
+
*/
|
|
2029
|
+
class CSSBindingDirective {
|
|
2030
|
+
/**
|
|
2031
|
+
* Creates an instance of CSSBindingDirective.
|
|
2032
|
+
* @param dataBinding - The binding to use in CSS.
|
|
2033
|
+
* @param targetAspect - The CSS property to target.
|
|
2034
|
+
*/
|
|
2035
|
+
constructor(dataBinding, targetAspect) {
|
|
2036
|
+
this.dataBinding = dataBinding;
|
|
2037
|
+
this.targetAspect = targetAspect;
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Creates a CSS fragment to interpolate into the CSS document.
|
|
2041
|
+
* @returns - the string to interpolate into CSS
|
|
2042
|
+
*/
|
|
2043
|
+
createCSS(add) {
|
|
2044
|
+
add(this);
|
|
2045
|
+
return `var(${this.targetAspect})`;
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Executed when this behavior is attached to a controller.
|
|
2049
|
+
* @param controller - Controls the behavior lifecycle.
|
|
2050
|
+
*/
|
|
2051
|
+
addedCallback(controller) {
|
|
2052
|
+
var _a;
|
|
2053
|
+
const element = controller.source;
|
|
2054
|
+
if (!element.$cssBindings) {
|
|
2055
|
+
element.$cssBindings = new Map();
|
|
2056
|
+
const setAttribute = element.setAttribute;
|
|
2057
|
+
element.setAttribute = (attr, value) => {
|
|
2058
|
+
setAttribute.call(element, attr, value);
|
|
2059
|
+
if (attr === "style") {
|
|
2060
|
+
element.$cssBindings.forEach((v, k) => handleChange(k, v.controller, v.observer));
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
const observer = (_a = controller[this.targetAspect]) !== null && _a !== void 0 ? _a : (controller[this.targetAspect] = this.dataBinding.createObserver(this, this));
|
|
2065
|
+
observer.controller = controller;
|
|
2066
|
+
controller.source.$cssBindings.set(this, { controller, observer });
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Executed when this behavior's host is connected.
|
|
2070
|
+
* @param controller - Controls the behavior lifecycle.
|
|
2071
|
+
*/
|
|
2072
|
+
connectedCallback(controller) {
|
|
2073
|
+
handleChange(this, controller, controller[this.targetAspect]);
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Executed when this behavior is detached from a controller.
|
|
2077
|
+
* @param controller - Controls the behavior lifecycle.
|
|
2078
|
+
*/
|
|
2079
|
+
removedCallback(controller) {
|
|
2080
|
+
if (controller.source.$cssBindings) {
|
|
2081
|
+
controller.source.$cssBindings.delete(this);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Called when a subject this instance has subscribed to changes.
|
|
2086
|
+
* @param subject - The subject of the change.
|
|
2087
|
+
* @param args - The event args detailing the change that occurred.
|
|
2088
|
+
*
|
|
2089
|
+
* @internal
|
|
2090
|
+
*/
|
|
2091
|
+
handleChange(_, observer) {
|
|
2092
|
+
handleChange(this, observer.controller, observer);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
CSSDirective.define(CSSBindingDirective);
|
|
2096
|
+
|
|
2097
|
+
const marker$1 = `${Math.random().toString(36).substring(2, 8)}`;
|
|
2098
|
+
let varId = 0;
|
|
2099
|
+
const nextCSSVariable = () => `--v${marker$1}${++varId}`;
|
|
1948
2100
|
function collectStyles(strings, values) {
|
|
1949
2101
|
const styles = [];
|
|
1950
2102
|
let cssString = "";
|
|
@@ -1955,7 +2107,13 @@ function collectStyles(strings, values) {
|
|
|
1955
2107
|
for (let i = 0, ii = strings.length - 1; i < ii; ++i) {
|
|
1956
2108
|
cssString += strings[i];
|
|
1957
2109
|
let value = values[i];
|
|
1958
|
-
if (
|
|
2110
|
+
if (isFunction(value)) {
|
|
2111
|
+
value = new CSSBindingDirective(oneWay(value), nextCSSVariable()).createCSS(add);
|
|
2112
|
+
}
|
|
2113
|
+
else if (value instanceof Binding) {
|
|
2114
|
+
value = new CSSBindingDirective(value, nextCSSVariable()).createCSS(add);
|
|
2115
|
+
}
|
|
2116
|
+
else if (CSSDirective.getForInstance(value) !== void 0) {
|
|
1959
2117
|
value = value.createCSS(add);
|
|
1960
2118
|
}
|
|
1961
2119
|
if (value instanceof ElementStyles || value instanceof CSSStyleSheet) {
|
|
@@ -2178,24 +2336,6 @@ function htmlDirective(options) {
|
|
|
2178
2336
|
HTMLDirective.define(type, options);
|
|
2179
2337
|
};
|
|
2180
2338
|
}
|
|
2181
|
-
/**
|
|
2182
|
-
* Captures a binding expression along with related information and capabilities.
|
|
2183
|
-
*
|
|
2184
|
-
* @public
|
|
2185
|
-
*/
|
|
2186
|
-
class Binding {
|
|
2187
|
-
/**
|
|
2188
|
-
* Creates a binding.
|
|
2189
|
-
* @param evaluate - Evaluates the binding.
|
|
2190
|
-
* @param policy - The security policy to associate with this binding.
|
|
2191
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
2192
|
-
*/
|
|
2193
|
-
constructor(evaluate, policy, isVolatile = false) {
|
|
2194
|
-
this.evaluate = evaluate;
|
|
2195
|
-
this.policy = policy;
|
|
2196
|
-
this.isVolatile = isVolatile;
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
2339
|
/**
|
|
2200
2340
|
* A base class used for attribute directives that don't need internal state.
|
|
2201
2341
|
* @public
|
|
@@ -2207,11 +2347,6 @@ class StatelessAttachedAttributeDirective {
|
|
|
2207
2347
|
*/
|
|
2208
2348
|
constructor(options) {
|
|
2209
2349
|
this.options = options;
|
|
2210
|
-
/**
|
|
2211
|
-
* Opts out of JSON stringification.
|
|
2212
|
-
* @internal
|
|
2213
|
-
*/
|
|
2214
|
-
this.toJSON = noop;
|
|
2215
2350
|
}
|
|
2216
2351
|
/**
|
|
2217
2352
|
* Creates a placeholder string based on the directive's index within the template.
|
|
@@ -2230,28 +2365,8 @@ class StatelessAttachedAttributeDirective {
|
|
|
2230
2365
|
return this;
|
|
2231
2366
|
}
|
|
2232
2367
|
}
|
|
2368
|
+
makeSerializationNoop(StatelessAttachedAttributeDirective);
|
|
2233
2369
|
|
|
2234
|
-
class OnChangeBinding extends Binding {
|
|
2235
|
-
createObserver(_, subscriber) {
|
|
2236
|
-
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
class OneTimeBinding extends Binding {
|
|
2240
|
-
constructor() {
|
|
2241
|
-
super(...arguments);
|
|
2242
|
-
/**
|
|
2243
|
-
* Opts out of JSON stringification.
|
|
2244
|
-
* @internal
|
|
2245
|
-
*/
|
|
2246
|
-
this.toJSON = noop;
|
|
2247
|
-
}
|
|
2248
|
-
createObserver() {
|
|
2249
|
-
return this;
|
|
2250
|
-
}
|
|
2251
|
-
bind(controller) {
|
|
2252
|
-
return this.evaluate(controller.source, controller.context);
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
2370
|
function updateContent(target, aspect, value, controller) {
|
|
2256
2371
|
// If there's no actual value, then this equates to the
|
|
2257
2372
|
// empty string for the purposes of content bindings.
|
|
@@ -2440,52 +2555,6 @@ class HTMLBindingDirective {
|
|
|
2440
2555
|
}
|
|
2441
2556
|
}
|
|
2442
2557
|
HTMLDirective.define(HTMLBindingDirective, { aspected: true });
|
|
2443
|
-
/**
|
|
2444
|
-
* Creates an standard binding.
|
|
2445
|
-
* @param expression - The binding to refresh when changed.
|
|
2446
|
-
* @param policy - The security policy to associate with th binding.
|
|
2447
|
-
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
2448
|
-
* @returns A binding configuration.
|
|
2449
|
-
* @public
|
|
2450
|
-
*/
|
|
2451
|
-
function bind(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
2452
|
-
return new OnChangeBinding(expression, policy, isVolatile);
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* Creates a one time binding
|
|
2456
|
-
* @param expression - The binding to refresh when signaled.
|
|
2457
|
-
* @param policy - The security policy to associate with th binding.
|
|
2458
|
-
* @returns A binding configuration.
|
|
2459
|
-
* @public
|
|
2460
|
-
*/
|
|
2461
|
-
function oneTime(expression, policy) {
|
|
2462
|
-
return new OneTimeBinding(expression, policy);
|
|
2463
|
-
}
|
|
2464
|
-
/**
|
|
2465
|
-
* Creates an event listener binding.
|
|
2466
|
-
* @param expression - The binding to invoke when the event is raised.
|
|
2467
|
-
* @param options - Event listener options.
|
|
2468
|
-
* @returns A binding configuration.
|
|
2469
|
-
* @public
|
|
2470
|
-
*/
|
|
2471
|
-
function listener(expression, options) {
|
|
2472
|
-
const config = new OnChangeBinding(expression);
|
|
2473
|
-
config.options = options;
|
|
2474
|
-
return config;
|
|
2475
|
-
}
|
|
2476
|
-
/**
|
|
2477
|
-
* Normalizes the input value into a binding.
|
|
2478
|
-
* @param value - The value to create the default binding for.
|
|
2479
|
-
* @returns A binding configuration for the provided value.
|
|
2480
|
-
* @public
|
|
2481
|
-
*/
|
|
2482
|
-
function normalizeBinding(value) {
|
|
2483
|
-
return isFunction(value)
|
|
2484
|
-
? bind(value)
|
|
2485
|
-
: value instanceof Binding
|
|
2486
|
-
? value
|
|
2487
|
-
: oneTime(() => value);
|
|
2488
|
-
}
|
|
2489
2558
|
|
|
2490
2559
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2491
2560
|
const parent = firstNode.parentNode;
|
|
@@ -2538,11 +2607,6 @@ class HTMLView {
|
|
|
2538
2607
|
* The length of the current collection within a repeat context.
|
|
2539
2608
|
*/
|
|
2540
2609
|
this.length = 0;
|
|
2541
|
-
/**
|
|
2542
|
-
* Opts out of JSON stringification.
|
|
2543
|
-
* @internal
|
|
2544
|
-
*/
|
|
2545
|
-
this.toJSON = noop;
|
|
2546
2610
|
this.firstChild = fragment.firstChild;
|
|
2547
2611
|
this.lastChild = fragment.lastChild;
|
|
2548
2612
|
}
|
|
@@ -2723,6 +2787,7 @@ class HTMLView {
|
|
|
2723
2787
|
}
|
|
2724
2788
|
}
|
|
2725
2789
|
}
|
|
2790
|
+
makeSerializationNoop(HTMLView);
|
|
2726
2791
|
Observable.defineProperty(HTMLView.prototype, "index");
|
|
2727
2792
|
Observable.defineProperty(HTMLView.prototype, "length");
|
|
2728
2793
|
|
|
@@ -3063,11 +3128,6 @@ class ViewTemplate {
|
|
|
3063
3128
|
constructor(html, factories = {}, policy) {
|
|
3064
3129
|
this.policy = policy;
|
|
3065
3130
|
this.result = null;
|
|
3066
|
-
/**
|
|
3067
|
-
* Opts out of JSON stringification.
|
|
3068
|
-
* @internal
|
|
3069
|
-
*/
|
|
3070
|
-
this.toJSON = noop;
|
|
3071
3131
|
this.html = html;
|
|
3072
3132
|
this.factories = factories;
|
|
3073
3133
|
}
|
|
@@ -3146,7 +3206,7 @@ class ViewTemplate {
|
|
|
3146
3206
|
let definition;
|
|
3147
3207
|
html += currentString;
|
|
3148
3208
|
if (isFunction(currentValue)) {
|
|
3149
|
-
currentValue = new HTMLBindingDirective(
|
|
3209
|
+
currentValue = new HTMLBindingDirective(oneWay(currentValue));
|
|
3150
3210
|
}
|
|
3151
3211
|
else if (currentValue instanceof Binding) {
|
|
3152
3212
|
currentValue = new HTMLBindingDirective(currentValue);
|
|
@@ -3160,6 +3220,7 @@ class ViewTemplate {
|
|
|
3160
3220
|
return new ViewTemplate(html + strings[strings.length - 1], factories, policy);
|
|
3161
3221
|
}
|
|
3162
3222
|
}
|
|
3223
|
+
makeSerializationNoop(ViewTemplate);
|
|
3163
3224
|
/**
|
|
3164
3225
|
* Transforms a template literal string into a ViewTemplate.
|
|
3165
3226
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -3215,6 +3276,20 @@ function when(condition, templateOrTemplateBinding) {
|
|
|
3215
3276
|
return (source, context) => dataBinding(source, context) ? templateBinding(source, context) : null;
|
|
3216
3277
|
}
|
|
3217
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);
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3218
3293
|
const defaultRepeatOptions = Object.freeze({
|
|
3219
3294
|
positioning: false,
|
|
3220
3295
|
recycle: true,
|
|
@@ -3252,8 +3327,8 @@ class RepeatBehavior {
|
|
|
3252
3327
|
this.bindView = bindWithoutPositioning;
|
|
3253
3328
|
/** @internal */
|
|
3254
3329
|
this.views = [];
|
|
3255
|
-
this.itemsBindingObserver = directive.dataBinding.createObserver(
|
|
3256
|
-
this.templateBindingObserver = directive.templateBinding.createObserver(
|
|
3330
|
+
this.itemsBindingObserver = directive.dataBinding.createObserver(this, directive);
|
|
3331
|
+
this.templateBindingObserver = directive.templateBinding.createObserver(this, directive);
|
|
3257
3332
|
if (directive.options.positioning) {
|
|
3258
3333
|
this.bindView = bindWithPositioning;
|
|
3259
3334
|
}
|
|
@@ -4040,11 +4115,6 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4040
4115
|
* If `null` then the element is managing its own rendering.
|
|
4041
4116
|
*/
|
|
4042
4117
|
this.view = null;
|
|
4043
|
-
/**
|
|
4044
|
-
* Opts out of JSON stringification.
|
|
4045
|
-
* @internal
|
|
4046
|
-
*/
|
|
4047
|
-
this.toJSON = noop;
|
|
4048
4118
|
this.source = element;
|
|
4049
4119
|
this.definition = definition;
|
|
4050
4120
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -4085,6 +4155,27 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4085
4155
|
Observable.track(this, isConnectedPropertyName);
|
|
4086
4156
|
return this.stage === 1 /* Stages.connected */;
|
|
4087
4157
|
}
|
|
4158
|
+
/**
|
|
4159
|
+
* The context the expression is evaluated against.
|
|
4160
|
+
*/
|
|
4161
|
+
get context() {
|
|
4162
|
+
var _a, _b;
|
|
4163
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.context) !== null && _b !== void 0 ? _b : ExecutionContext.default;
|
|
4164
|
+
}
|
|
4165
|
+
/**
|
|
4166
|
+
* Indicates whether the controller is bound.
|
|
4167
|
+
*/
|
|
4168
|
+
get isBound() {
|
|
4169
|
+
var _a, _b;
|
|
4170
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.isBound) !== null && _b !== void 0 ? _b : false;
|
|
4171
|
+
}
|
|
4172
|
+
/**
|
|
4173
|
+
* Indicates how the source's lifetime relates to the controller's lifetime.
|
|
4174
|
+
*/
|
|
4175
|
+
get sourceLifetime() {
|
|
4176
|
+
var _a;
|
|
4177
|
+
return (_a = this.view) === null || _a === void 0 ? void 0 : _a.sourceLifetime;
|
|
4178
|
+
}
|
|
4088
4179
|
/**
|
|
4089
4180
|
* Gets/sets the template used to render the component.
|
|
4090
4181
|
* @remarks
|
|
@@ -4147,6 +4238,14 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4147
4238
|
this.addStyles(value);
|
|
4148
4239
|
}
|
|
4149
4240
|
}
|
|
4241
|
+
/**
|
|
4242
|
+
* Registers an unbind handler with the controller.
|
|
4243
|
+
* @param behavior - An object to call when the controller unbinds.
|
|
4244
|
+
*/
|
|
4245
|
+
onUnbind(behavior) {
|
|
4246
|
+
var _a;
|
|
4247
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.onUnbind(behavior);
|
|
4248
|
+
}
|
|
4150
4249
|
/**
|
|
4151
4250
|
* Adds the behavior to the component.
|
|
4152
4251
|
* @param behavior - The behavior to add.
|
|
@@ -4379,6 +4478,7 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4379
4478
|
elementControllerStrategy = strategy;
|
|
4380
4479
|
}
|
|
4381
4480
|
}
|
|
4481
|
+
makeSerializationNoop(ElementController);
|
|
4382
4482
|
// Set default strategy for ElementController
|
|
4383
4483
|
ElementController.setStrategy(ElementController);
|
|
4384
4484
|
/**
|
|
@@ -4548,4 +4648,4 @@ function customElement(nameOrDef) {
|
|
|
4548
4648
|
|
|
4549
4649
|
DOM.setPolicy(DOMPolicy.create());
|
|
4550
4650
|
|
|
4551
|
-
export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, 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,
|
|
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 };
|