@microsoft/fast-element 2.0.0-beta.20 → 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 +54 -0
- package/CHANGELOG.md +21 -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 +26 -13
- package/dist/dts/dom-policy.d.ts +15 -0
- package/dist/dts/index.d.ts +6 -2
- package/dist/dts/interfaces.d.ts +6 -5
- package/dist/dts/metadata.d.ts +6 -5
- package/dist/dts/pending-task.d.ts +19 -7
- package/dist/dts/platform.d.ts +10 -2
- 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/dts/utilities.d.ts +3 -2
- 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 -9
- package/dist/esm/context.js +24 -3
- package/dist/esm/debug.js +1 -0
- package/dist/esm/di/di.js +5 -5
- package/dist/esm/dom-policy.js +9 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/interfaces.js +3 -3
- package/dist/esm/metadata.js +11 -8
- package/dist/esm/observation/observable.js +3 -6
- package/dist/esm/pending-task.js +13 -1
- package/dist/esm/platform.js +10 -1
- 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/esm/utilities.js +3 -2
- package/dist/fast-element.api.json +1827 -663
- package/dist/fast-element.d.ts +167 -43
- package/dist/fast-element.debug.js +227 -120
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +226 -120
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +134 -82
- package/docs/api-report.md +54 -57
- 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
|
|
|
@@ -97,7 +97,7 @@ if (globalThis.FAST === void 0) {
|
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* The FAST global.
|
|
100
|
-
* @
|
|
100
|
+
* @public
|
|
101
101
|
*/
|
|
102
102
|
const FAST = globalThis.FAST;
|
|
103
103
|
if (FAST.getById === void 0) {
|
|
@@ -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.
|
|
@@ -283,7 +291,10 @@ function safeURL(tagName, aspect, aspectName, sink) {
|
|
|
283
291
|
};
|
|
284
292
|
}
|
|
285
293
|
function block(tagName, aspect, aspectName, sink) {
|
|
286
|
-
throw
|
|
294
|
+
throw FAST.error(1209 /* Message.blockedByDOMPolicy */, {
|
|
295
|
+
aspectName,
|
|
296
|
+
tagName: tagName !== null && tagName !== void 0 ? tagName : "text",
|
|
297
|
+
});
|
|
287
298
|
}
|
|
288
299
|
const defaultDOMElementGuards = {
|
|
289
300
|
a: {
|
|
@@ -577,6 +588,10 @@ function tryGuard(aspectGuards, tagName, aspect, aspectName, sink) {
|
|
|
577
588
|
}
|
|
578
589
|
}
|
|
579
590
|
}
|
|
591
|
+
/**
|
|
592
|
+
* A helper for creating DOM policies.
|
|
593
|
+
* @public
|
|
594
|
+
*/
|
|
580
595
|
const DOMPolicy = Object.freeze({
|
|
581
596
|
/**
|
|
582
597
|
* Creates a new DOM Policy object.
|
|
@@ -917,10 +932,6 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
917
932
|
this.propertyName = void 0;
|
|
918
933
|
this.notifier = void 0;
|
|
919
934
|
this.next = void 0;
|
|
920
|
-
/**
|
|
921
|
-
* Opts out of JSON stringification.
|
|
922
|
-
*/
|
|
923
|
-
this.toJSON = noop;
|
|
924
935
|
}
|
|
925
936
|
setMode(isAsync) {
|
|
926
937
|
this.isAsync = this.needsQueue = isAsync;
|
|
@@ -1022,6 +1033,7 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
1022
1033
|
}
|
|
1023
1034
|
}
|
|
1024
1035
|
}
|
|
1036
|
+
makeSerializationNoop(ExpressionNotifierImplementation);
|
|
1025
1037
|
return Object.freeze({
|
|
1026
1038
|
/**
|
|
1027
1039
|
* @internal
|
|
@@ -1745,6 +1757,74 @@ function lengthOf(array) {
|
|
|
1745
1757
|
return array.length;
|
|
1746
1758
|
}
|
|
1747
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
|
+
|
|
1748
1828
|
let DefaultStyleStrategy;
|
|
1749
1829
|
function reduceStyles(styles) {
|
|
1750
1830
|
return styles
|
|
@@ -1873,6 +1953,85 @@ function cssDirective() {
|
|
|
1873
1953
|
};
|
|
1874
1954
|
}
|
|
1875
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}`;
|
|
1876
2035
|
function collectStyles(strings, values) {
|
|
1877
2036
|
const styles = [];
|
|
1878
2037
|
let cssString = "";
|
|
@@ -1883,7 +2042,13 @@ function collectStyles(strings, values) {
|
|
|
1883
2042
|
for (let i = 0, ii = strings.length - 1; i < ii; ++i) {
|
|
1884
2043
|
cssString += strings[i];
|
|
1885
2044
|
let value = values[i];
|
|
1886
|
-
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) {
|
|
1887
2052
|
value = value.createCSS(add);
|
|
1888
2053
|
}
|
|
1889
2054
|
if (value instanceof ElementStyles || value instanceof CSSStyleSheet) {
|
|
@@ -2106,24 +2271,6 @@ function htmlDirective(options) {
|
|
|
2106
2271
|
HTMLDirective.define(type, options);
|
|
2107
2272
|
};
|
|
2108
2273
|
}
|
|
2109
|
-
/**
|
|
2110
|
-
* Captures a binding expression along with related information and capabilities.
|
|
2111
|
-
*
|
|
2112
|
-
* @public
|
|
2113
|
-
*/
|
|
2114
|
-
class Binding {
|
|
2115
|
-
/**
|
|
2116
|
-
* Creates a binding.
|
|
2117
|
-
* @param evaluate - Evaluates the binding.
|
|
2118
|
-
* @param policy - The security policy to associate with this binding.
|
|
2119
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
2120
|
-
*/
|
|
2121
|
-
constructor(evaluate, policy, isVolatile = false) {
|
|
2122
|
-
this.evaluate = evaluate;
|
|
2123
|
-
this.policy = policy;
|
|
2124
|
-
this.isVolatile = isVolatile;
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
2274
|
/**
|
|
2128
2275
|
* A base class used for attribute directives that don't need internal state.
|
|
2129
2276
|
* @public
|
|
@@ -2135,11 +2282,6 @@ class StatelessAttachedAttributeDirective {
|
|
|
2135
2282
|
*/
|
|
2136
2283
|
constructor(options) {
|
|
2137
2284
|
this.options = options;
|
|
2138
|
-
/**
|
|
2139
|
-
* Opts out of JSON stringification.
|
|
2140
|
-
* @internal
|
|
2141
|
-
*/
|
|
2142
|
-
this.toJSON = noop;
|
|
2143
2285
|
}
|
|
2144
2286
|
/**
|
|
2145
2287
|
* Creates a placeholder string based on the directive's index within the template.
|
|
@@ -2158,28 +2300,8 @@ class StatelessAttachedAttributeDirective {
|
|
|
2158
2300
|
return this;
|
|
2159
2301
|
}
|
|
2160
2302
|
}
|
|
2303
|
+
makeSerializationNoop(StatelessAttachedAttributeDirective);
|
|
2161
2304
|
|
|
2162
|
-
class OnChangeBinding extends Binding {
|
|
2163
|
-
createObserver(_, subscriber) {
|
|
2164
|
-
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
class OneTimeBinding extends Binding {
|
|
2168
|
-
constructor() {
|
|
2169
|
-
super(...arguments);
|
|
2170
|
-
/**
|
|
2171
|
-
* Opts out of JSON stringification.
|
|
2172
|
-
* @internal
|
|
2173
|
-
*/
|
|
2174
|
-
this.toJSON = noop;
|
|
2175
|
-
}
|
|
2176
|
-
createObserver() {
|
|
2177
|
-
return this;
|
|
2178
|
-
}
|
|
2179
|
-
bind(controller) {
|
|
2180
|
-
return this.evaluate(controller.source, controller.context);
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
2305
|
function updateContent(target, aspect, value, controller) {
|
|
2184
2306
|
// If there's no actual value, then this equates to the
|
|
2185
2307
|
// empty string for the purposes of content bindings.
|
|
@@ -2368,52 +2490,6 @@ class HTMLBindingDirective {
|
|
|
2368
2490
|
}
|
|
2369
2491
|
}
|
|
2370
2492
|
HTMLDirective.define(HTMLBindingDirective, { aspected: true });
|
|
2371
|
-
/**
|
|
2372
|
-
* Creates an standard binding.
|
|
2373
|
-
* @param expression - The binding to refresh when changed.
|
|
2374
|
-
* @param policy - The security policy to associate with th binding.
|
|
2375
|
-
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
2376
|
-
* @returns A binding configuration.
|
|
2377
|
-
* @public
|
|
2378
|
-
*/
|
|
2379
|
-
function bind(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
2380
|
-
return new OnChangeBinding(expression, policy, isVolatile);
|
|
2381
|
-
}
|
|
2382
|
-
/**
|
|
2383
|
-
* Creates a one time binding
|
|
2384
|
-
* @param expression - The binding to refresh when signaled.
|
|
2385
|
-
* @param policy - The security policy to associate with th binding.
|
|
2386
|
-
* @returns A binding configuration.
|
|
2387
|
-
* @public
|
|
2388
|
-
*/
|
|
2389
|
-
function oneTime(expression, policy) {
|
|
2390
|
-
return new OneTimeBinding(expression, policy);
|
|
2391
|
-
}
|
|
2392
|
-
/**
|
|
2393
|
-
* Creates an event listener binding.
|
|
2394
|
-
* @param expression - The binding to invoke when the event is raised.
|
|
2395
|
-
* @param options - Event listener options.
|
|
2396
|
-
* @returns A binding configuration.
|
|
2397
|
-
* @public
|
|
2398
|
-
*/
|
|
2399
|
-
function listener(expression, options) {
|
|
2400
|
-
const config = new OnChangeBinding(expression);
|
|
2401
|
-
config.options = options;
|
|
2402
|
-
return config;
|
|
2403
|
-
}
|
|
2404
|
-
/**
|
|
2405
|
-
* Normalizes the input value into a binding.
|
|
2406
|
-
* @param value - The value to create the default binding for.
|
|
2407
|
-
* @returns A binding configuration for the provided value.
|
|
2408
|
-
* @public
|
|
2409
|
-
*/
|
|
2410
|
-
function normalizeBinding(value) {
|
|
2411
|
-
return isFunction(value)
|
|
2412
|
-
? bind(value)
|
|
2413
|
-
: value instanceof Binding
|
|
2414
|
-
? value
|
|
2415
|
-
: oneTime(() => value);
|
|
2416
|
-
}
|
|
2417
2493
|
|
|
2418
2494
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2419
2495
|
const parent = firstNode.parentNode;
|
|
@@ -2466,11 +2542,6 @@ class HTMLView {
|
|
|
2466
2542
|
* The length of the current collection within a repeat context.
|
|
2467
2543
|
*/
|
|
2468
2544
|
this.length = 0;
|
|
2469
|
-
/**
|
|
2470
|
-
* Opts out of JSON stringification.
|
|
2471
|
-
* @internal
|
|
2472
|
-
*/
|
|
2473
|
-
this.toJSON = noop;
|
|
2474
2545
|
this.firstChild = fragment.firstChild;
|
|
2475
2546
|
this.lastChild = fragment.lastChild;
|
|
2476
2547
|
}
|
|
@@ -2651,6 +2722,7 @@ class HTMLView {
|
|
|
2651
2722
|
}
|
|
2652
2723
|
}
|
|
2653
2724
|
}
|
|
2725
|
+
makeSerializationNoop(HTMLView);
|
|
2654
2726
|
Observable.defineProperty(HTMLView.prototype, "index");
|
|
2655
2727
|
Observable.defineProperty(HTMLView.prototype, "length");
|
|
2656
2728
|
|
|
@@ -2991,11 +3063,6 @@ class ViewTemplate {
|
|
|
2991
3063
|
constructor(html, factories = {}, policy) {
|
|
2992
3064
|
this.policy = policy;
|
|
2993
3065
|
this.result = null;
|
|
2994
|
-
/**
|
|
2995
|
-
* Opts out of JSON stringification.
|
|
2996
|
-
* @internal
|
|
2997
|
-
*/
|
|
2998
|
-
this.toJSON = noop;
|
|
2999
3066
|
this.html = html;
|
|
3000
3067
|
this.factories = factories;
|
|
3001
3068
|
}
|
|
@@ -3074,7 +3141,7 @@ class ViewTemplate {
|
|
|
3074
3141
|
let definition;
|
|
3075
3142
|
html += currentString;
|
|
3076
3143
|
if (isFunction(currentValue)) {
|
|
3077
|
-
currentValue = new HTMLBindingDirective(
|
|
3144
|
+
currentValue = new HTMLBindingDirective(oneWay(currentValue));
|
|
3078
3145
|
}
|
|
3079
3146
|
else if (currentValue instanceof Binding) {
|
|
3080
3147
|
currentValue = new HTMLBindingDirective(currentValue);
|
|
@@ -3088,6 +3155,7 @@ class ViewTemplate {
|
|
|
3088
3155
|
return new ViewTemplate(html + strings[strings.length - 1], factories, policy);
|
|
3089
3156
|
}
|
|
3090
3157
|
}
|
|
3158
|
+
makeSerializationNoop(ViewTemplate);
|
|
3091
3159
|
/**
|
|
3092
3160
|
* Transforms a template literal string into a ViewTemplate.
|
|
3093
3161
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -3143,6 +3211,20 @@ function when(condition, templateOrTemplateBinding) {
|
|
|
3143
3211
|
return (source, context) => dataBinding(source, context) ? templateBinding(source, context) : null;
|
|
3144
3212
|
}
|
|
3145
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
|
+
|
|
3146
3228
|
const defaultRepeatOptions = Object.freeze({
|
|
3147
3229
|
positioning: false,
|
|
3148
3230
|
recycle: true,
|
|
@@ -3180,8 +3262,8 @@ class RepeatBehavior {
|
|
|
3180
3262
|
this.bindView = bindWithoutPositioning;
|
|
3181
3263
|
/** @internal */
|
|
3182
3264
|
this.views = [];
|
|
3183
|
-
this.itemsBindingObserver = directive.dataBinding.createObserver(
|
|
3184
|
-
this.templateBindingObserver = directive.templateBinding.createObserver(
|
|
3265
|
+
this.itemsBindingObserver = directive.dataBinding.createObserver(this, directive);
|
|
3266
|
+
this.templateBindingObserver = directive.templateBinding.createObserver(this, directive);
|
|
3185
3267
|
if (directive.options.positioning) {
|
|
3186
3268
|
this.bindView = bindWithPositioning;
|
|
3187
3269
|
}
|
|
@@ -3968,11 +4050,6 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
3968
4050
|
* If `null` then the element is managing its own rendering.
|
|
3969
4051
|
*/
|
|
3970
4052
|
this.view = null;
|
|
3971
|
-
/**
|
|
3972
|
-
* Opts out of JSON stringification.
|
|
3973
|
-
* @internal
|
|
3974
|
-
*/
|
|
3975
|
-
this.toJSON = noop;
|
|
3976
4053
|
this.source = element;
|
|
3977
4054
|
this.definition = definition;
|
|
3978
4055
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -4013,6 +4090,27 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4013
4090
|
Observable.track(this, isConnectedPropertyName);
|
|
4014
4091
|
return this.stage === 1 /* Stages.connected */;
|
|
4015
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
|
+
}
|
|
4016
4114
|
/**
|
|
4017
4115
|
* Gets/sets the template used to render the component.
|
|
4018
4116
|
* @remarks
|
|
@@ -4075,6 +4173,14 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4075
4173
|
this.addStyles(value);
|
|
4076
4174
|
}
|
|
4077
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
|
+
}
|
|
4078
4184
|
/**
|
|
4079
4185
|
* Adds the behavior to the component.
|
|
4080
4186
|
* @param behavior - The behavior to add.
|
|
@@ -4307,6 +4413,7 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4307
4413
|
elementControllerStrategy = strategy;
|
|
4308
4414
|
}
|
|
4309
4415
|
}
|
|
4416
|
+
makeSerializationNoop(ElementController);
|
|
4310
4417
|
// Set default strategy for ElementController
|
|
4311
4418
|
ElementController.setStrategy(ElementController);
|
|
4312
4419
|
/**
|
|
@@ -4388,7 +4495,6 @@ class StyleElementStrategy {
|
|
|
4388
4495
|
removeStylesFrom(target) {
|
|
4389
4496
|
target = usableStyleTarget(normalizeStyleTarget(target));
|
|
4390
4497
|
const styles = target.querySelectorAll(`.${this.styleClass}`);
|
|
4391
|
-
styles[0].parentNode;
|
|
4392
4498
|
for (let i = 0, ii = styles.length; i < ii; ++i) {
|
|
4393
4499
|
target.removeChild(styles[i]);
|
|
4394
4500
|
}
|
|
@@ -4477,4 +4583,4 @@ function customElement(nameOrDef) {
|
|
|
4477
4583
|
|
|
4478
4584
|
DOM.setPolicy(DOMPolicy.create());
|
|
4479
4585
|
|
|
4480
|
-
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 };
|