@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
|
@@ -17,6 +17,7 @@ const debugMessages = {
|
|
|
17
17
|
[1206 /* directCallToHTMLTagNotAllowed */]: "Calling html`` as a normal function invalidates the security guarantees provided by FAST.",
|
|
18
18
|
[1207 /* onlySetTemplatePolicyOnce */]: "The DOM Policy for an HTML template can only be set once.",
|
|
19
19
|
[1208 /* cannotSetTemplatePolicyAfterCompilation */]: "The DOM Policy cannot be set after a template is compiled.",
|
|
20
|
+
[1209 /* blockedByDOMPolicy */]: "'${aspectName}' on '${tagName}' is blocked by the current DOMPolicy.",
|
|
20
21
|
[1401 /* missingElementDefinition */]: "Missing FASTElement definition.",
|
|
21
22
|
[1501 /* noRegistrationForContext */]: "No registration for Context/Interface '${name}'.",
|
|
22
23
|
[1502 /* noFactoryForResolver */]: "Dependency injection resolver for '${key}' returned a null factory.",
|
|
@@ -108,17 +109,17 @@ switch (kernelMode) {
|
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
111
|
* Determines whether or not an object is a function.
|
|
111
|
-
* @
|
|
112
|
+
* @public
|
|
112
113
|
*/
|
|
113
114
|
const isFunction = (object) => typeof object === "function";
|
|
114
115
|
/**
|
|
115
116
|
* Determines whether or not an object is a string.
|
|
116
|
-
* @
|
|
117
|
+
* @public
|
|
117
118
|
*/
|
|
118
119
|
const isString = (object) => typeof object === "string";
|
|
119
120
|
/**
|
|
120
121
|
* A function which does nothing.
|
|
121
|
-
* @
|
|
122
|
+
* @public
|
|
122
123
|
*/
|
|
123
124
|
const noop = () => void 0;
|
|
124
125
|
|
|
@@ -161,7 +162,7 @@ if (globalThis.FAST === void 0) {
|
|
|
161
162
|
}
|
|
162
163
|
/**
|
|
163
164
|
* The FAST global.
|
|
164
|
-
* @
|
|
165
|
+
* @public
|
|
165
166
|
*/
|
|
166
167
|
const FAST = globalThis.FAST;
|
|
167
168
|
if (FAST.getById === void 0) {
|
|
@@ -237,6 +238,14 @@ function createMetadataLocator() {
|
|
|
237
238
|
return metadata;
|
|
238
239
|
};
|
|
239
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
|
+
}
|
|
240
249
|
|
|
241
250
|
/**
|
|
242
251
|
* The type of HTML aspect to target.
|
|
@@ -347,7 +356,10 @@ function safeURL(tagName, aspect, aspectName, sink) {
|
|
|
347
356
|
};
|
|
348
357
|
}
|
|
349
358
|
function block(tagName, aspect, aspectName, sink) {
|
|
350
|
-
throw
|
|
359
|
+
throw FAST.error(1209 /* Message.blockedByDOMPolicy */, {
|
|
360
|
+
aspectName,
|
|
361
|
+
tagName: tagName !== null && tagName !== void 0 ? tagName : "text",
|
|
362
|
+
});
|
|
351
363
|
}
|
|
352
364
|
const defaultDOMElementGuards = {
|
|
353
365
|
a: {
|
|
@@ -641,6 +653,10 @@ function tryGuard(aspectGuards, tagName, aspect, aspectName, sink) {
|
|
|
641
653
|
}
|
|
642
654
|
}
|
|
643
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* A helper for creating DOM policies.
|
|
658
|
+
* @public
|
|
659
|
+
*/
|
|
644
660
|
const DOMPolicy = Object.freeze({
|
|
645
661
|
/**
|
|
646
662
|
* Creates a new DOM Policy object.
|
|
@@ -981,10 +997,6 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
981
997
|
this.propertyName = void 0;
|
|
982
998
|
this.notifier = void 0;
|
|
983
999
|
this.next = void 0;
|
|
984
|
-
/**
|
|
985
|
-
* Opts out of JSON stringification.
|
|
986
|
-
*/
|
|
987
|
-
this.toJSON = noop;
|
|
988
1000
|
}
|
|
989
1001
|
setMode(isAsync) {
|
|
990
1002
|
this.isAsync = this.needsQueue = isAsync;
|
|
@@ -1086,6 +1098,7 @@ const Observable = FAST.getById(KernelServiceId.observable, () => {
|
|
|
1086
1098
|
}
|
|
1087
1099
|
}
|
|
1088
1100
|
}
|
|
1101
|
+
makeSerializationNoop(ExpressionNotifierImplementation);
|
|
1089
1102
|
return Object.freeze({
|
|
1090
1103
|
/**
|
|
1091
1104
|
* @internal
|
|
@@ -1809,6 +1822,74 @@ function lengthOf(array) {
|
|
|
1809
1822
|
return array.length;
|
|
1810
1823
|
}
|
|
1811
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
|
+
|
|
1812
1893
|
let DefaultStyleStrategy;
|
|
1813
1894
|
function reduceStyles(styles) {
|
|
1814
1895
|
return styles
|
|
@@ -1937,6 +2018,85 @@ function cssDirective() {
|
|
|
1937
2018
|
};
|
|
1938
2019
|
}
|
|
1939
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}`;
|
|
1940
2100
|
function collectStyles(strings, values) {
|
|
1941
2101
|
const styles = [];
|
|
1942
2102
|
let cssString = "";
|
|
@@ -1947,7 +2107,13 @@ function collectStyles(strings, values) {
|
|
|
1947
2107
|
for (let i = 0, ii = strings.length - 1; i < ii; ++i) {
|
|
1948
2108
|
cssString += strings[i];
|
|
1949
2109
|
let value = values[i];
|
|
1950
|
-
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) {
|
|
1951
2117
|
value = value.createCSS(add);
|
|
1952
2118
|
}
|
|
1953
2119
|
if (value instanceof ElementStyles || value instanceof CSSStyleSheet) {
|
|
@@ -2170,24 +2336,6 @@ function htmlDirective(options) {
|
|
|
2170
2336
|
HTMLDirective.define(type, options);
|
|
2171
2337
|
};
|
|
2172
2338
|
}
|
|
2173
|
-
/**
|
|
2174
|
-
* Captures a binding expression along with related information and capabilities.
|
|
2175
|
-
*
|
|
2176
|
-
* @public
|
|
2177
|
-
*/
|
|
2178
|
-
class Binding {
|
|
2179
|
-
/**
|
|
2180
|
-
* Creates a binding.
|
|
2181
|
-
* @param evaluate - Evaluates the binding.
|
|
2182
|
-
* @param policy - The security policy to associate with this binding.
|
|
2183
|
-
* @param isVolatile - Indicates whether the binding is volatile.
|
|
2184
|
-
*/
|
|
2185
|
-
constructor(evaluate, policy, isVolatile = false) {
|
|
2186
|
-
this.evaluate = evaluate;
|
|
2187
|
-
this.policy = policy;
|
|
2188
|
-
this.isVolatile = isVolatile;
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
2339
|
/**
|
|
2192
2340
|
* A base class used for attribute directives that don't need internal state.
|
|
2193
2341
|
* @public
|
|
@@ -2199,11 +2347,6 @@ class StatelessAttachedAttributeDirective {
|
|
|
2199
2347
|
*/
|
|
2200
2348
|
constructor(options) {
|
|
2201
2349
|
this.options = options;
|
|
2202
|
-
/**
|
|
2203
|
-
* Opts out of JSON stringification.
|
|
2204
|
-
* @internal
|
|
2205
|
-
*/
|
|
2206
|
-
this.toJSON = noop;
|
|
2207
2350
|
}
|
|
2208
2351
|
/**
|
|
2209
2352
|
* Creates a placeholder string based on the directive's index within the template.
|
|
@@ -2222,28 +2365,8 @@ class StatelessAttachedAttributeDirective {
|
|
|
2222
2365
|
return this;
|
|
2223
2366
|
}
|
|
2224
2367
|
}
|
|
2368
|
+
makeSerializationNoop(StatelessAttachedAttributeDirective);
|
|
2225
2369
|
|
|
2226
|
-
class OnChangeBinding extends Binding {
|
|
2227
|
-
createObserver(_, subscriber) {
|
|
2228
|
-
return Observable.binding(this.evaluate, subscriber, this.isVolatile);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
class OneTimeBinding extends Binding {
|
|
2232
|
-
constructor() {
|
|
2233
|
-
super(...arguments);
|
|
2234
|
-
/**
|
|
2235
|
-
* Opts out of JSON stringification.
|
|
2236
|
-
* @internal
|
|
2237
|
-
*/
|
|
2238
|
-
this.toJSON = noop;
|
|
2239
|
-
}
|
|
2240
|
-
createObserver() {
|
|
2241
|
-
return this;
|
|
2242
|
-
}
|
|
2243
|
-
bind(controller) {
|
|
2244
|
-
return this.evaluate(controller.source, controller.context);
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
2370
|
function updateContent(target, aspect, value, controller) {
|
|
2248
2371
|
// If there's no actual value, then this equates to the
|
|
2249
2372
|
// empty string for the purposes of content bindings.
|
|
@@ -2432,52 +2555,6 @@ class HTMLBindingDirective {
|
|
|
2432
2555
|
}
|
|
2433
2556
|
}
|
|
2434
2557
|
HTMLDirective.define(HTMLBindingDirective, { aspected: true });
|
|
2435
|
-
/**
|
|
2436
|
-
* Creates an standard binding.
|
|
2437
|
-
* @param expression - The binding to refresh when changed.
|
|
2438
|
-
* @param policy - The security policy to associate with th binding.
|
|
2439
|
-
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
2440
|
-
* @returns A binding configuration.
|
|
2441
|
-
* @public
|
|
2442
|
-
*/
|
|
2443
|
-
function bind(expression, policy, isVolatile = Observable.isVolatileBinding(expression)) {
|
|
2444
|
-
return new OnChangeBinding(expression, policy, isVolatile);
|
|
2445
|
-
}
|
|
2446
|
-
/**
|
|
2447
|
-
* Creates a one time binding
|
|
2448
|
-
* @param expression - The binding to refresh when signaled.
|
|
2449
|
-
* @param policy - The security policy to associate with th binding.
|
|
2450
|
-
* @returns A binding configuration.
|
|
2451
|
-
* @public
|
|
2452
|
-
*/
|
|
2453
|
-
function oneTime(expression, policy) {
|
|
2454
|
-
return new OneTimeBinding(expression, policy);
|
|
2455
|
-
}
|
|
2456
|
-
/**
|
|
2457
|
-
* Creates an event listener binding.
|
|
2458
|
-
* @param expression - The binding to invoke when the event is raised.
|
|
2459
|
-
* @param options - Event listener options.
|
|
2460
|
-
* @returns A binding configuration.
|
|
2461
|
-
* @public
|
|
2462
|
-
*/
|
|
2463
|
-
function listener(expression, options) {
|
|
2464
|
-
const config = new OnChangeBinding(expression);
|
|
2465
|
-
config.options = options;
|
|
2466
|
-
return config;
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* Normalizes the input value into a binding.
|
|
2470
|
-
* @param value - The value to create the default binding for.
|
|
2471
|
-
* @returns A binding configuration for the provided value.
|
|
2472
|
-
* @public
|
|
2473
|
-
*/
|
|
2474
|
-
function normalizeBinding(value) {
|
|
2475
|
-
return isFunction(value)
|
|
2476
|
-
? bind(value)
|
|
2477
|
-
: value instanceof Binding
|
|
2478
|
-
? value
|
|
2479
|
-
: oneTime(() => value);
|
|
2480
|
-
}
|
|
2481
2558
|
|
|
2482
2559
|
function removeNodeSequence(firstNode, lastNode) {
|
|
2483
2560
|
const parent = firstNode.parentNode;
|
|
@@ -2530,11 +2607,6 @@ class HTMLView {
|
|
|
2530
2607
|
* The length of the current collection within a repeat context.
|
|
2531
2608
|
*/
|
|
2532
2609
|
this.length = 0;
|
|
2533
|
-
/**
|
|
2534
|
-
* Opts out of JSON stringification.
|
|
2535
|
-
* @internal
|
|
2536
|
-
*/
|
|
2537
|
-
this.toJSON = noop;
|
|
2538
2610
|
this.firstChild = fragment.firstChild;
|
|
2539
2611
|
this.lastChild = fragment.lastChild;
|
|
2540
2612
|
}
|
|
@@ -2715,6 +2787,7 @@ class HTMLView {
|
|
|
2715
2787
|
}
|
|
2716
2788
|
}
|
|
2717
2789
|
}
|
|
2790
|
+
makeSerializationNoop(HTMLView);
|
|
2718
2791
|
Observable.defineProperty(HTMLView.prototype, "index");
|
|
2719
2792
|
Observable.defineProperty(HTMLView.prototype, "length");
|
|
2720
2793
|
|
|
@@ -3055,11 +3128,6 @@ class ViewTemplate {
|
|
|
3055
3128
|
constructor(html, factories = {}, policy) {
|
|
3056
3129
|
this.policy = policy;
|
|
3057
3130
|
this.result = null;
|
|
3058
|
-
/**
|
|
3059
|
-
* Opts out of JSON stringification.
|
|
3060
|
-
* @internal
|
|
3061
|
-
*/
|
|
3062
|
-
this.toJSON = noop;
|
|
3063
3131
|
this.html = html;
|
|
3064
3132
|
this.factories = factories;
|
|
3065
3133
|
}
|
|
@@ -3138,7 +3206,7 @@ class ViewTemplate {
|
|
|
3138
3206
|
let definition;
|
|
3139
3207
|
html += currentString;
|
|
3140
3208
|
if (isFunction(currentValue)) {
|
|
3141
|
-
currentValue = new HTMLBindingDirective(
|
|
3209
|
+
currentValue = new HTMLBindingDirective(oneWay(currentValue));
|
|
3142
3210
|
}
|
|
3143
3211
|
else if (currentValue instanceof Binding) {
|
|
3144
3212
|
currentValue = new HTMLBindingDirective(currentValue);
|
|
@@ -3152,6 +3220,7 @@ class ViewTemplate {
|
|
|
3152
3220
|
return new ViewTemplate(html + strings[strings.length - 1], factories, policy);
|
|
3153
3221
|
}
|
|
3154
3222
|
}
|
|
3223
|
+
makeSerializationNoop(ViewTemplate);
|
|
3155
3224
|
/**
|
|
3156
3225
|
* Transforms a template literal string into a ViewTemplate.
|
|
3157
3226
|
* @param strings - The string fragments that are interpolated with the values.
|
|
@@ -3207,6 +3276,20 @@ function when(condition, templateOrTemplateBinding) {
|
|
|
3207
3276
|
return (source, context) => dataBinding(source, context) ? templateBinding(source, context) : null;
|
|
3208
3277
|
}
|
|
3209
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
|
+
|
|
3210
3293
|
const defaultRepeatOptions = Object.freeze({
|
|
3211
3294
|
positioning: false,
|
|
3212
3295
|
recycle: true,
|
|
@@ -3244,8 +3327,8 @@ class RepeatBehavior {
|
|
|
3244
3327
|
this.bindView = bindWithoutPositioning;
|
|
3245
3328
|
/** @internal */
|
|
3246
3329
|
this.views = [];
|
|
3247
|
-
this.itemsBindingObserver = directive.dataBinding.createObserver(
|
|
3248
|
-
this.templateBindingObserver = directive.templateBinding.createObserver(
|
|
3330
|
+
this.itemsBindingObserver = directive.dataBinding.createObserver(this, directive);
|
|
3331
|
+
this.templateBindingObserver = directive.templateBinding.createObserver(this, directive);
|
|
3249
3332
|
if (directive.options.positioning) {
|
|
3250
3333
|
this.bindView = bindWithPositioning;
|
|
3251
3334
|
}
|
|
@@ -4032,11 +4115,6 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4032
4115
|
* If `null` then the element is managing its own rendering.
|
|
4033
4116
|
*/
|
|
4034
4117
|
this.view = null;
|
|
4035
|
-
/**
|
|
4036
|
-
* Opts out of JSON stringification.
|
|
4037
|
-
* @internal
|
|
4038
|
-
*/
|
|
4039
|
-
this.toJSON = noop;
|
|
4040
4118
|
this.source = element;
|
|
4041
4119
|
this.definition = definition;
|
|
4042
4120
|
const shadowOptions = definition.shadowOptions;
|
|
@@ -4077,6 +4155,27 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4077
4155
|
Observable.track(this, isConnectedPropertyName);
|
|
4078
4156
|
return this.stage === 1 /* Stages.connected */;
|
|
4079
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
|
+
}
|
|
4080
4179
|
/**
|
|
4081
4180
|
* Gets/sets the template used to render the component.
|
|
4082
4181
|
* @remarks
|
|
@@ -4139,6 +4238,14 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4139
4238
|
this.addStyles(value);
|
|
4140
4239
|
}
|
|
4141
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
|
+
}
|
|
4142
4249
|
/**
|
|
4143
4250
|
* Adds the behavior to the component.
|
|
4144
4251
|
* @param behavior - The behavior to add.
|
|
@@ -4371,6 +4478,7 @@ class ElementController extends PropertyChangeNotifier {
|
|
|
4371
4478
|
elementControllerStrategy = strategy;
|
|
4372
4479
|
}
|
|
4373
4480
|
}
|
|
4481
|
+
makeSerializationNoop(ElementController);
|
|
4374
4482
|
// Set default strategy for ElementController
|
|
4375
4483
|
ElementController.setStrategy(ElementController);
|
|
4376
4484
|
/**
|
|
@@ -4452,7 +4560,6 @@ class StyleElementStrategy {
|
|
|
4452
4560
|
removeStylesFrom(target) {
|
|
4453
4561
|
target = usableStyleTarget(normalizeStyleTarget(target));
|
|
4454
4562
|
const styles = target.querySelectorAll(`.${this.styleClass}`);
|
|
4455
|
-
styles[0].parentNode;
|
|
4456
4563
|
for (let i = 0, ii = styles.length; i < ii; ++i) {
|
|
4457
4564
|
target.removeChild(styles[i]);
|
|
4458
4565
|
}
|
|
@@ -4541,4 +4648,4 @@ function customElement(nameOrDef) {
|
|
|
4541
4648
|
|
|
4542
4649
|
DOM.setPolicy(DOMPolicy.create());
|
|
4543
4650
|
|
|
4544
|
-
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 };
|