@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
package/dist/fast-element.js
CHANGED
|
@@ -44,17 +44,17 @@ switch (kernelMode) {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Determines whether or not an object is a function.
|
|
47
|
-
* @
|
|
47
|
+
* @public
|
|
48
48
|
*/
|
|
49
49
|
const isFunction = (object) => typeof object === "function";
|
|
50
50
|
/**
|
|
51
51
|
* Determines whether or not an object is a string.
|
|
52
|
-
* @
|
|
52
|
+
* @public
|
|
53
53
|
*/
|
|
54
54
|
const isString = (object) => typeof object === "string";
|
|
55
55
|
/**
|
|
56
56
|
* A function which does nothing.
|
|
57
|
-
* @
|
|
57
|
+
* @public
|
|
58
58
|
*/
|
|
59
59
|
const noop = () => void 0;
|
|
60
60
|
|
|
@@ -173,6 +173,14 @@ function createMetadataLocator() {
|
|
|
173
173
|
return metadata;
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Makes a type noop for JSON serialization.
|
|
178
|
+
* @param type - The type to make noop for JSON serialization.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
function makeSerializationNoop(type) {
|
|
182
|
+
type.prototype.toJSON = noop;
|
|
183
|
+
}
|
|
176
184
|
|
|
177
185
|
/**
|
|
178
186
|
* The type of HTML aspect to target.
|
|
@@ -924,10 +932,6 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
924
932
|
this.propertyName = void 0;
|
|
925
933
|
this.notifier = void 0;
|
|
926
934
|
this.next = void 0;
|
|
927
|
-
/**
|
|
928
|
-
* Opts out of JSON stringification.
|
|
929
|
-
*/
|
|
930
|
-
this.toJSON = noop;
|
|
931
935
|
}
|
|
932
936
|
setMode(isAsync) {
|
|
933
937
|
this.isAsync = this.needsQueue = isAsync;
|
|
@@ -1029,6 +1033,7 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
1029
1033
|
}
|
|
1030
1034
|
}
|
|
1031
1035
|
}
|
|
1036
|
+
makeSerializationNoop(ExpressionNotifierImplementation);
|
|
1032
1037
|
return Object.freeze({
|
|
1033
1038
|
/**
|
|
1034
1039
|
* @internal
|
|
@@ -1752,6 +1757,74 @@ function lengthOf(array) {
|
|
|
1752
1757
|
return array.length;
|
|
1753
1758
|
}
|
|
1754
1759
|
|
|
1760
|
+
/**
|
|
1761
|
+
* Captures a binding expression along with related information and capabilities.
|
|
1762
|
+
*
|
|
1763
|
+
* @public
|
|
1764
|
+
*/
|
|
1765
|
+
class Binding {
|
|
1766
|
+
/**
|
|
1767
|
+
* Creates a binding.
|
|
1768
|
+
* @param evaluate - Evaluates the binding.
|
|
1769
|
+
* @param policy - The security policy to associate with this binding.
|
|
1770
|
+
* @param isVolatile - Indicates whether the binding is volatile.
|
|
1771
|
+
*/
|
|
1772
|
+
constructor(evaluate, policy, isVolatile = false) {
|
|
1773
|
+
this.evaluate = evaluate;
|
|
1774
|
+
this.policy = policy;
|
|
1775
|
+
this.isVolatile = isVolatile;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
class OneWayBinding extends Binding {
|
|
1780
|
+
createObserver(subscriber) {
|
|
1781
|
+
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Creates an standard binding.
|
|
1786
|
+
* @param expression - The binding to refresh when changed.
|
|
1787
|
+
* @param policy - The security policy to associate with th binding.
|
|
1788
|
+
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
1789
|
+
* @returns A binding configuration.
|
|
1790
|
+
* @public
|
|
1791
|
+
*/
|
|
1792
|
+
function oneWay(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
1793
|
+
return new OneWayBinding(expression, policy, isVolatile);
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Creates an event listener binding.
|
|
1797
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
1798
|
+
* @param options - Event listener options.
|
|
1799
|
+
* @returns A binding configuration.
|
|
1800
|
+
* @public
|
|
1801
|
+
*/
|
|
1802
|
+
function listener(expression, options) {
|
|
1803
|
+
const config = new OneWayBinding(expression);
|
|
1804
|
+
config.options = options;
|
|
1805
|
+
return config;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
class OneTimeBinding extends Binding {
|
|
1809
|
+
createObserver() {
|
|
1810
|
+
return this;
|
|
1811
|
+
}
|
|
1812
|
+
bind(controller) {
|
|
1813
|
+
return this.evaluate(controller.source, controller.context);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
makeSerializationNoop(OneTimeBinding);
|
|
1817
|
+
/**
|
|
1818
|
+
* Creates a one time binding
|
|
1819
|
+
* @param expression - The binding to refresh when signaled.
|
|
1820
|
+
* @param policy - The security policy to associate with th binding.
|
|
1821
|
+
* @returns A binding configuration.
|
|
1822
|
+
* @public
|
|
1823
|
+
*/
|
|
1824
|
+
function oneTime(expression, policy) {
|
|
1825
|
+
return new OneTimeBinding(expression, policy);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1755
1828
|
let DefaultStyleStrategy;
|
|
1756
1829
|
function reduceStyles(styles) {
|
|
1757
1830
|
return styles
|
|
@@ -1880,6 +1953,85 @@ function cssDirective() {
|
|
|
1880
1953
|
};
|
|
1881
1954
|
}
|
|
1882
1955
|
|
|
1956
|
+
function handleChange(directive, controller, observer) {
|
|
1957
|
+
controller.source.style.setProperty(directive.targetAspect, observer.bind(controller));
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Enables bindings in CSS.
|
|
1961
|
+
*
|
|
1962
|
+
* @public
|
|
1963
|
+
*/
|
|
1964
|
+
class CSSBindingDirective {
|
|
1965
|
+
/**
|
|
1966
|
+
* Creates an instance of CSSBindingDirective.
|
|
1967
|
+
* @param dataBinding - The binding to use in CSS.
|
|
1968
|
+
* @param targetAspect - The CSS property to target.
|
|
1969
|
+
*/
|
|
1970
|
+
constructor(dataBinding, targetAspect) {
|
|
1971
|
+
this.dataBinding = dataBinding;
|
|
1972
|
+
this.targetAspect = targetAspect;
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Creates a CSS fragment to interpolate into the CSS document.
|
|
1976
|
+
* @returns - the string to interpolate into CSS
|
|
1977
|
+
*/
|
|
1978
|
+
createCSS(add) {
|
|
1979
|
+
add(this);
|
|
1980
|
+
return `var(${this.targetAspect})`;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Executed when this behavior is attached to a controller.
|
|
1984
|
+
* @param controller - Controls the behavior lifecycle.
|
|
1985
|
+
*/
|
|
1986
|
+
addedCallback(controller) {
|
|
1987
|
+
var _a;
|
|
1988
|
+
const element = controller.source;
|
|
1989
|
+
if (!element.$cssBindings) {
|
|
1990
|
+
element.$cssBindings = new Map();
|
|
1991
|
+
const setAttribute = element.setAttribute;
|
|
1992
|
+
element.setAttribute = (attr, value) => {
|
|
1993
|
+
setAttribute.call(element, attr, value);
|
|
1994
|
+
if (attr === "style") {
|
|
1995
|
+
element.$cssBindings.forEach((v, k) => handleChange(k, v.controller, v.observer));
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
const observer = (_a = controller[this.targetAspect]) !== null && _a !== void 0 ? _a : (controller[this.targetAspect] = this.dataBinding.createObserver(this, this));
|
|
2000
|
+
observer.controller = controller;
|
|
2001
|
+
controller.source.$cssBindings.set(this, { controller, observer });
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Executed when this behavior's host is connected.
|
|
2005
|
+
* @param controller - Controls the behavior lifecycle.
|
|
2006
|
+
*/
|
|
2007
|
+
connectedCallback(controller) {
|
|
2008
|
+
handleChange(this, controller, controller[this.targetAspect]);
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Executed when this behavior is detached from a controller.
|
|
2012
|
+
* @param controller - Controls the behavior lifecycle.
|
|
2013
|
+
*/
|
|
2014
|
+
removedCallback(controller) {
|
|
2015
|
+
if (controller.source.$cssBindings) {
|
|
2016
|
+
controller.source.$cssBindings.delete(this);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Called when a subject this instance has subscribed to changes.
|
|
2021
|
+
* @param subject - The subject of the change.
|
|
2022
|
+
* @param args - The event args detailing the change that occurred.
|
|
2023
|
+
*
|
|
2024
|
+
* @internal
|
|
2025
|
+
*/
|
|
2026
|
+
handleChange(_, observer) {
|
|
2027
|
+
handleChange(this, observer.controller, observer);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
CSSDirective.define(CSSBindingDirective);
|
|
2031
|
+
|
|
2032
|
+
const marker$1 = `${Math.random().toString(36).substring(2, 8)}`;
|
|
2033
|
+
let varId = 0;
|
|
2034
|
+
const nextCSSVariable = () => `--v${marker$1}${++varId}`;
|
|
1883
2035
|
function collectStyles(strings, values) {
|
|
1884
2036
|
const styles = [];
|
|
1885
2037
|
let cssString = "";
|
|
@@ -1890,7 +2042,13 @@ function collectStyles(strings, values) {
|
|
|
1890
2042
|
for (let i = 0, ii = strings.length - 1; i < ii; ++i) {
|
|
1891
2043
|
cssString += strings[i];
|
|
1892
2044
|
let value = values[i];
|
|
1893
|
-
if (
|
|
2045
|
+
if (isFunction(value)) {
|
|
2046
|
+
value = new CSSBindingDirective(oneWay(value), nextCSSVariable()).createCSS(add);
|
|
2047
|
+
}
|
|
2048
|
+
else if (value instanceof Binding) {
|
|
2049
|
+
value = new CSSBindingDirective(value, nextCSSVariable()).createCSS(add);
|
|
2050
|
+
}
|
|
2051
|
+
else if (CSSDirective.getForInstance(value) !== void 0) {
|
|
1894
2052
|
value = value.createCSS(add);
|
|
1895
2053
|
}
|
|
1896
2054
|
if (value instanceof ElementStyles || value instanceof CSSStyleSheet) {
|
|
@@ -2113,24 +2271,6 @@ function htmlDirective(options) {
|
|
|
2113
2271
|
HTMLDirective.define(type, options);
|
|
2114
2272
|
};
|
|
2115
2273
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
* Captures a binding expression along with related information and capabilities.
|
|
2118
|
-
*
|
|
2119
|
-
* @public
|
|
2120
|
-
*/
|
|
2121
|
-
class Binding {
|
|
2122
|
-
/**
|
|
2123
|
-
* Creates a binding.
|
|
2124
|
-
* @param evaluate - Evaluates the binding.
|
|
2125
|
-
* @param policy - The security policy to associate with this binding.
|
|
2126
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
2127
|
-
*/
|
|
2128
|
-
constructor(evaluate, policy, isVolatile = false) {
|
|
2129
|
-
this.evaluate = evaluate;
|
|
2130
|
-
this.policy = policy;
|
|
2131
|
-
this.isVolatile = isVolatile;
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
2274
|
/**
|
|
2135
2275
|
* A base class used for attribute directives that don't need internal state.
|
|
2136
2276
|
* @public
|
|
@@ -2142,11 +2282,6 @@ class StatelessAttachedAttributeDirective {
|
|
|
2142
2282
|
*/
|
|
2143
2283
|
constructor(options) {
|
|
2144
2284
|
this.options = options;
|
|
2145
|
-
/**
|
|
2146
|
-
* Opts out of JSON stringification.
|
|
2147
|
-
* @internal
|
|
2148
|
-
*/
|
|
2149
|
-
this.toJSON = noop;
|
|
2150
2285
|
}
|
|
2151
2286
|
/**
|
|
2152
2287
|
* Creates a placeholder string based on the directive's index within the template.
|
|
@@ -2165,28 +2300,8 @@ class StatelessAttachedAttributeDirective {
|
|
|
2165
2300
|
return this;
|
|
2166
2301
|
}
|
|
2167
2302
|
}
|
|
2303
|
+
makeSerializationNoop(StatelessAttachedAttributeDirective);
|
|
2168
2304
|
|
|
2169
|
-
class OnChangeBinding extends Binding {
|
|
2170
|
-
createObserver(_, subscriber) {
|
|
2171
|
-
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
class OneTimeBinding extends Binding {
|
|
2175
|
-
constructor() {
|
|
2176
|
-
super(...arguments);
|
|
2177
|
-
/**
|
|
2178
|
-
* Opts out of JSON stringification.
|
|
2179
|
-
* @internal
|
|
2180
|
-
*/
|
|
2181
|
-
this.toJSON = noop;
|
|
2182
|
-
}
|
|
2183
|
-
createObserver() {
|
|
2184
|
-
return this;
|
|
2185
|
-
}
|
|
2186
|
-
bind(controller) {
|
|
2187
|
-
return this.evaluate(controller.source, controller.context);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
2305
|
function updateContent(target, aspect, value, controller) {
|
|
2191
2306
|
// If there's no actual value, then this equates to the
|
|
2192
2307
|
// empty string for the purposes of content bindings.
|
|
@@ -2375,52 +2490,6 @@ class HTMLBindingDirective {
|
|
|
2375
2490
|
}
|
|
2376
2491
|
}
|
|
2377
2492
|
HTMLDirective.define(HTMLBindingDirective, { aspected: true });
|
|
2378
|
-
/**
|
|
2379
|
-
* Creates an standard binding.
|
|
2380
|
-
* @param expression - The binding to refresh when changed.
|
|
2381
|
-
* @param policy - The security policy to associate with th binding.
|
|
2382
|
-
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
2383
|
-
* @returns A binding configuration.
|
|
2384
|
-
* @public
|
|
2385
|
-
*/
|
|
2386
|
-
function bind(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
2387
|
-
return new OnChangeBinding(expression, policy, isVolatile);
|
|
2388
|
-
}
|
|
2389
|
-
/**
|
|
2390
|
-
* Creates a one time binding
|
|
2391
|
-
* @param expression - The binding to refresh when signaled.
|
|
2392
|
-
* @param policy - The security policy to associate with th binding.
|
|
2393
|
-
* @returns A binding configuration.
|
|
2394
|
-
* @public
|
|
2395
|
-
*/
|
|
2396
|
-
function oneTime(expression, policy) {
|
|
2397
|
-
return new OneTimeBinding(expression, policy);
|
|
2398
|
-
}
|
|
2399
|
-
/**
|
|
2400
|
-
* Creates an event listener binding.
|
|
2401
|
-
* @param expression - The binding to invoke when the event is raised.
|
|
2402
|
-
* @param options - Event listener options.
|
|
2403
|
-
* @returns A binding configuration.
|
|
2404
|
-
* @public
|
|
2405
|
-
*/
|
|
2406
|
-
function listener(expression, options) {
|
|
2407
|
-
const config = new OnChangeBinding(expression);
|
|
2408
|
-
config.options = options;
|
|
2409
|
-
return config;
|
|
2410
|
-
}
|
|
2411
|
-
/**
|
|
2412
|
-
* Normalizes the input value into a binding.
|
|
2413
|
-
* @param value - The value to create the default binding for.
|
|
2414
|
-
* @returns A binding configuration for the provided value.
|
|
2415
|
-
* @public
|
|
2416
|
-
*/
|
|
2417
|
-
function normalizeBinding(value) {
|
|
2418
|
-
return isFunction(value)
|
|
2419
|
-
? bind(value)
|
|
2420
|
-
: value instanceof Binding
|
|
2421
|
-
? value
|
|
2422
|
-
: oneTime(() => value);
|
|
2423
|
-
}
|
|
2424
2493
|
|
|
2425
2494
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2426
2495
|
const parent = firstNode.parentNode;
|
|
@@ -2473,11 +2542,6 @@ class HTMLView {
|
|
|
2473
2542
|
* The length of the current collection within a repeat context.
|
|
2474
2543
|
*/
|
|
2475
2544
|
this.length = 0;
|
|
2476
|
-
/**
|
|
2477
|
-
* Opts out of JSON stringification.
|
|
2478
|
-
* @internal
|
|
2479
|
-
*/
|
|
2480
|
-
this.toJSON = noop;
|
|
2481
2545
|
this.firstChild = fragment.firstChild;
|
|
2482
2546
|
this.lastChild = fragment.lastChild;
|
|
2483
2547
|
}
|
|
@@ -2658,6 +2722,7 @@ class HTMLView {
|
|
|
2658
2722
|
}
|
|
2659
2723
|
}
|
|
2660
2724
|
}
|
|
2725
|
+
makeSerializationNoop(HTMLView);
|
|
2661
2726
|
Observable.defineProperty(HTMLView.prototype, "index");
|
|
2662
2727
|
Observable.defineProperty(HTMLView.prototype, "length");
|
|
2663
2728
|
|
|
@@ -2998,11 +3063,6 @@ class ViewTemplate {
|
|
|
2998
3063
|
constructor(html, factories = {}, policy) {
|
|
2999
3064
|
this.policy = policy;
|
|
3000
3065
|
this.result = null;
|
|
3001
|
-
/**
|
|
3002
|
-
* Opts out of JSON stringification.
|
|
3003
|
-
* @internal
|
|
3004
|
-
*/
|
|
3005
|
-
this.toJSON = noop;
|
|
3006
3066
|
this.html = html;
|
|
3007
3067
|
this.factories = factories;
|
|
3008
3068
|
}
|
|
@@ -3081,7 +3141,7 @@ class ViewTemplate {
|
|
|
3081
3141
|
let definition;
|
|
3082
3142
|
html += currentString;
|
|
3083
3143
|
if (isFunction(currentValue)) {
|
|
3084
|
-
currentValue = new HTMLBindingDirective(
|
|
3144
|
+
currentValue = new HTMLBindingDirective(oneWay(currentValue));
|
|
3085
3145
|
}
|
|
3086
3146
|
else if (currentValue instanceof Binding) {
|
|
3087
3147
|
currentValue = new HTMLBindingDirective(currentValue);
|
|
@@ -3095,6 +3155,7 @@ class ViewTemplate {
|
|
|
3095
3155
|
return new ViewTemplate(html + strings[strings.length - 1], factories, policy);
|
|
3096
3156
|
}
|
|
3097
3157
|
}
|
|
3158
|
+
makeSerializationNoop(ViewTemplate);
|
|
3098
3159
|
/**
|
|
3099
3160
|
* Transforms a template literal string into a ViewTemplate.
|
|
3100
3161
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -3150,6 +3211,20 @@ function when(condition, templateOrTemplateBinding) {
|
|
|
3150
3211
|
return (source, context) => dataBinding(source, context) ? templateBinding(source, context) : null;
|
|
3151
3212
|
}
|
|
3152
3213
|
|
|
3214
|
+
/**
|
|
3215
|
+
* Normalizes the input value into a binding.
|
|
3216
|
+
* @param value - The value to create the default binding for.
|
|
3217
|
+
* @returns A binding configuration for the provided value.
|
|
3218
|
+
* @public
|
|
3219
|
+
*/
|
|
3220
|
+
function normalizeBinding(value) {
|
|
3221
|
+
return isFunction(value)
|
|
3222
|
+
? oneWay(value)
|
|
3223
|
+
: value instanceof Binding
|
|
3224
|
+
? value
|
|
3225
|
+
: oneTime(() => value);
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3153
3228
|
const defaultRepeatOptions = Object.freeze({
|
|
3154
3229
|
positioning: false,
|
|
3155
3230
|
recycle: true,
|
|
@@ -3187,8 +3262,8 @@ class RepeatBehavior {
|
|
|
3187
3262
|
this.bindView = bindWithoutPositioning;
|
|
3188
3263
|
/** @internal */
|
|
3189
3264
|
this.views = [];
|
|
3190
|
-
this.itemsBindingObserver = directive.dataBinding.createObserver(
|
|
3191
|
-
this.templateBindingObserver = directive.templateBinding.createObserver(
|
|
3265
|
+
this.itemsBindingObserver = directive.dataBinding.createObserver(this, directive);
|
|
3266
|
+
this.templateBindingObserver = directive.templateBinding.createObserver(this, directive);
|
|
3192
3267
|
if (directive.options.positioning) {
|
|
3193
3268
|
this.bindView = bindWithPositioning;
|
|
3194
3269
|
}
|
|
@@ -3975,11 +4050,6 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3975
4050
|
* If `null` then the element is managing its own rendering.
|
|
3976
4051
|
*/
|
|
3977
4052
|
this.view = null;
|
|
3978
|
-
/**
|
|
3979
|
-
* Opts out of JSON stringification.
|
|
3980
|
-
* @internal
|
|
3981
|
-
*/
|
|
3982
|
-
this.toJSON = noop;
|
|
3983
4053
|
this.source = element;
|
|
3984
4054
|
this.definition = definition;
|
|
3985
4055
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -4020,6 +4090,27 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4020
4090
|
Observable.track(this, isConnectedPropertyName);
|
|
4021
4091
|
return this.stage === 1 /* Stages.connected */;
|
|
4022
4092
|
}
|
|
4093
|
+
/**
|
|
4094
|
+
* The context the expression is evaluated against.
|
|
4095
|
+
*/
|
|
4096
|
+
get context() {
|
|
4097
|
+
var _a, _b;
|
|
4098
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.context) !== null && _b !== void 0 ? _b : ExecutionContext.default;
|
|
4099
|
+
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Indicates whether the controller is bound.
|
|
4102
|
+
*/
|
|
4103
|
+
get isBound() {
|
|
4104
|
+
var _a, _b;
|
|
4105
|
+
return (_b = (_a = this.view) === null || _a === void 0 ? void 0 : _a.isBound) !== null && _b !== void 0 ? _b : false;
|
|
4106
|
+
}
|
|
4107
|
+
/**
|
|
4108
|
+
* Indicates how the source's lifetime relates to the controller's lifetime.
|
|
4109
|
+
*/
|
|
4110
|
+
get sourceLifetime() {
|
|
4111
|
+
var _a;
|
|
4112
|
+
return (_a = this.view) === null || _a === void 0 ? void 0 : _a.sourceLifetime;
|
|
4113
|
+
}
|
|
4023
4114
|
/**
|
|
4024
4115
|
* Gets/sets the template used to render the component.
|
|
4025
4116
|
* @remarks
|
|
@@ -4082,6 +4173,14 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4082
4173
|
this.addStyles(value);
|
|
4083
4174
|
}
|
|
4084
4175
|
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Registers an unbind handler with the controller.
|
|
4178
|
+
* @param behavior - An object to call when the controller unbinds.
|
|
4179
|
+
*/
|
|
4180
|
+
onUnbind(behavior) {
|
|
4181
|
+
var _a;
|
|
4182
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.onUnbind(behavior);
|
|
4183
|
+
}
|
|
4085
4184
|
/**
|
|
4086
4185
|
* Adds the behavior to the component.
|
|
4087
4186
|
* @param behavior - The behavior to add.
|
|
@@ -4314,6 +4413,7 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4314
4413
|
elementControllerStrategy = strategy;
|
|
4315
4414
|
}
|
|
4316
4415
|
}
|
|
4416
|
+
makeSerializationNoop(ElementController);
|
|
4317
4417
|
// Set default strategy for ElementController
|
|
4318
4418
|
ElementController.setStrategy(ElementController);
|
|
4319
4419
|
/**
|
|
@@ -4483,4 +4583,4 @@ function customElement(nameOrDef) {
|
|
|
4483
4583
|
|
|
4484
4584
|
DOM.setPolicy(DOMPolicy.create());
|
|
4485
4585
|
|
|
4486
|
-
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,
|
|
4586
|
+
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 };
|