@microsoft/fast-element 2.0.0-beta.16 → 2.0.0-beta.18

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.
Files changed (63) hide show
  1. package/CHANGELOG.json +36 -0
  2. package/CHANGELOG.md +18 -1
  3. package/dist/dts/components/element-controller.d.ts +5 -0
  4. package/dist/dts/dom-policy.d.ts +68 -0
  5. package/dist/dts/dom.d.ts +116 -0
  6. package/dist/dts/index.d.ts +3 -2
  7. package/dist/dts/index.rollup.d.ts +0 -1
  8. package/dist/dts/index.rollup.debug.d.ts +0 -1
  9. package/dist/dts/interfaces.d.ts +15 -24
  10. package/dist/dts/polyfills.d.ts +0 -1
  11. package/dist/dts/templating/binding-signal.d.ts +3 -1
  12. package/dist/dts/templating/binding-two-way.d.ts +3 -1
  13. package/dist/dts/templating/binding.d.ts +16 -5
  14. package/dist/dts/templating/compiler.d.ts +11 -13
  15. package/dist/dts/templating/dangerous-html.d.ts +18 -0
  16. package/dist/dts/templating/html-directive.d.ts +54 -118
  17. package/dist/dts/templating/node-observation.d.ts +11 -1
  18. package/dist/dts/templating/ref.d.ts +4 -0
  19. package/dist/dts/templating/render.d.ts +30 -6
  20. package/dist/dts/templating/repeat.d.ts +1 -5
  21. package/dist/dts/templating/template.d.ts +44 -13
  22. package/dist/dts/templating/view.d.ts +8 -3
  23. package/dist/dts/testing/fakes.d.ts +1 -0
  24. package/dist/dts/utilities.d.ts +39 -0
  25. package/dist/esm/components/attributes.js +1 -1
  26. package/dist/esm/components/element-controller.js +6 -1
  27. package/dist/esm/debug.js +4 -1
  28. package/dist/esm/dom-policy.js +337 -0
  29. package/dist/esm/dom.js +117 -0
  30. package/dist/esm/index.js +2 -1
  31. package/dist/esm/index.rollup.debug.js +3 -1
  32. package/dist/esm/index.rollup.js +3 -1
  33. package/dist/esm/observation/observable.js +5 -1
  34. package/dist/esm/platform.js +1 -1
  35. package/dist/esm/polyfills.js +3 -7
  36. package/dist/esm/templating/binding-signal.js +9 -3
  37. package/dist/esm/templating/binding-two-way.js +9 -3
  38. package/dist/esm/templating/binding.js +40 -55
  39. package/dist/esm/templating/children.js +8 -4
  40. package/dist/esm/templating/compiler.js +31 -38
  41. package/dist/esm/templating/dangerous-html.js +23 -0
  42. package/dist/esm/templating/html-directive.js +42 -133
  43. package/dist/esm/templating/node-observation.js +14 -8
  44. package/dist/esm/templating/ref.js +1 -1
  45. package/dist/esm/templating/render.js +17 -6
  46. package/dist/esm/templating/repeat.js +2 -6
  47. package/dist/esm/templating/template.js +86 -56
  48. package/dist/esm/templating/view.js +6 -0
  49. package/dist/esm/testing/fakes.js +2 -0
  50. package/dist/esm/testing/fixture.js +1 -1
  51. package/dist/esm/utilities.js +68 -0
  52. package/dist/fast-element.api.json +1088 -608
  53. package/dist/fast-element.d.ts +194 -147
  54. package/dist/fast-element.debug.js +745 -381
  55. package/dist/fast-element.debug.min.js +1 -1
  56. package/dist/fast-element.js +716 -355
  57. package/dist/fast-element.min.js +1 -1
  58. package/dist/fast-element.untrimmed.d.ts +208 -145
  59. package/docs/api-report.md +74 -56
  60. package/package.json +5 -1
  61. package/yarn-error.log +177 -0
  62. package/dist/dts/templating/dom.d.ts +0 -41
  63. package/dist/esm/templating/dom.js +0 -49
@@ -0,0 +1,337 @@
1
+ import { DOMAspect } from "./dom.js";
2
+ import { isString } from "./interfaces.js";
3
+ function safeURL(tagName, aspect, aspectName, sink) {
4
+ return (target, name, value, ...rest) => {
5
+ if (isString(value)) {
6
+ value = value.replace("javascript:", "");
7
+ }
8
+ sink(target, name, value, ...rest);
9
+ };
10
+ }
11
+ function block(tagName, aspect, aspectName, sink) {
12
+ throw new Error(`${aspectName} on ${tagName !== null && tagName !== void 0 ? tagName : "text"} is blocked by the current DOMPolicy.`);
13
+ }
14
+ const defaultDOMElementGuards = {
15
+ a: {
16
+ [DOMAspect.attribute]: {
17
+ href: safeURL,
18
+ },
19
+ [DOMAspect.property]: {
20
+ href: safeURL,
21
+ },
22
+ },
23
+ area: {
24
+ [DOMAspect.attribute]: {
25
+ href: safeURL,
26
+ },
27
+ [DOMAspect.property]: {
28
+ href: safeURL,
29
+ },
30
+ },
31
+ button: {
32
+ [DOMAspect.attribute]: {
33
+ formaction: safeURL,
34
+ },
35
+ [DOMAspect.property]: {
36
+ formAction: safeURL,
37
+ },
38
+ },
39
+ embed: {
40
+ [DOMAspect.attribute]: {
41
+ src: block,
42
+ },
43
+ [DOMAspect.property]: {
44
+ src: block,
45
+ },
46
+ },
47
+ form: {
48
+ [DOMAspect.attribute]: {
49
+ action: safeURL,
50
+ },
51
+ [DOMAspect.property]: {
52
+ action: safeURL,
53
+ },
54
+ },
55
+ frame: {
56
+ [DOMAspect.attribute]: {
57
+ src: safeURL,
58
+ },
59
+ [DOMAspect.property]: {
60
+ src: safeURL,
61
+ },
62
+ },
63
+ iframe: {
64
+ [DOMAspect.attribute]: {
65
+ src: safeURL,
66
+ },
67
+ [DOMAspect.property]: {
68
+ src: safeURL,
69
+ srcdoc: block,
70
+ },
71
+ },
72
+ input: {
73
+ [DOMAspect.attribute]: {
74
+ formaction: safeURL,
75
+ },
76
+ [DOMAspect.property]: {
77
+ formAction: safeURL,
78
+ },
79
+ },
80
+ link: {
81
+ [DOMAspect.attribute]: {
82
+ href: block,
83
+ },
84
+ [DOMAspect.property]: {
85
+ href: block,
86
+ },
87
+ },
88
+ object: {
89
+ [DOMAspect.attribute]: {
90
+ codebase: block,
91
+ data: block,
92
+ },
93
+ [DOMAspect.property]: {
94
+ codeBase: block,
95
+ data: block,
96
+ },
97
+ },
98
+ script: {
99
+ [DOMAspect.attribute]: {
100
+ src: block,
101
+ text: block,
102
+ },
103
+ [DOMAspect.property]: {
104
+ src: block,
105
+ text: block,
106
+ innerText: block,
107
+ textContent: block,
108
+ },
109
+ },
110
+ style: {
111
+ [DOMAspect.property]: {
112
+ innerText: block,
113
+ textContent: block,
114
+ },
115
+ },
116
+ };
117
+ const blockedEvents = {
118
+ onabort: block,
119
+ onauxclick: block,
120
+ onbeforeinput: block,
121
+ onbeforematch: block,
122
+ onblur: block,
123
+ oncancel: block,
124
+ oncanplay: block,
125
+ oncanplaythrough: block,
126
+ onchange: block,
127
+ onclick: block,
128
+ onclose: block,
129
+ oncontextlost: block,
130
+ oncontextmenu: block,
131
+ oncontextrestored: block,
132
+ oncopy: block,
133
+ oncuechange: block,
134
+ oncut: block,
135
+ ondblclick: block,
136
+ ondrag: block,
137
+ ondragend: block,
138
+ ondragenter: block,
139
+ ondragleave: block,
140
+ ondragover: block,
141
+ ondragstart: block,
142
+ ondrop: block,
143
+ ondurationchange: block,
144
+ onemptied: block,
145
+ onended: block,
146
+ onerror: block,
147
+ onfocus: block,
148
+ onformdata: block,
149
+ oninput: block,
150
+ oninvalid: block,
151
+ onkeydown: block,
152
+ onkeypress: block,
153
+ onkeyup: block,
154
+ onload: block,
155
+ onloadeddata: block,
156
+ onloadedmetadata: block,
157
+ onloadstart: block,
158
+ onmousedown: block,
159
+ onmouseenter: block,
160
+ onmouseleave: block,
161
+ onmousemove: block,
162
+ onmouseout: block,
163
+ onmouseover: block,
164
+ onmouseup: block,
165
+ onpaste: block,
166
+ onpause: block,
167
+ onplay: block,
168
+ onplaying: block,
169
+ onprogress: block,
170
+ onratechange: block,
171
+ onreset: block,
172
+ onresize: block,
173
+ onscroll: block,
174
+ onsecuritypolicyviolation: block,
175
+ onseeked: block,
176
+ onseeking: block,
177
+ onselect: block,
178
+ onslotchange: block,
179
+ onstalled: block,
180
+ onsubmit: block,
181
+ onsuspend: block,
182
+ ontimeupdate: block,
183
+ ontoggle: block,
184
+ onvolumechange: block,
185
+ onwaiting: block,
186
+ onwebkitanimationend: block,
187
+ onwebkitanimationiteration: block,
188
+ onwebkitanimationstart: block,
189
+ onwebkittransitionend: block,
190
+ onwheel: block,
191
+ };
192
+ const defaultDOMGuards = {
193
+ elements: defaultDOMElementGuards,
194
+ aspects: {
195
+ [DOMAspect.attribute]: Object.assign({}, blockedEvents),
196
+ [DOMAspect.property]: Object.assign({ innerHTML: block }, blockedEvents),
197
+ [DOMAspect.event]: Object.assign({}, blockedEvents),
198
+ },
199
+ };
200
+ function createDomSinkGuards(config, defaults) {
201
+ const result = {};
202
+ for (const name in defaults) {
203
+ const overrideValue = config[name];
204
+ const defaultValue = defaults[name];
205
+ switch (overrideValue) {
206
+ case null:
207
+ // remove the default
208
+ break;
209
+ case undefined:
210
+ // keep the default
211
+ result[name] = defaultValue;
212
+ break;
213
+ default:
214
+ // override the default
215
+ result[name] = overrideValue;
216
+ break;
217
+ }
218
+ }
219
+ // add any new sinks that were not overrides
220
+ for (const name in config) {
221
+ if (!(name in result)) {
222
+ result[name] = config[name];
223
+ }
224
+ }
225
+ return Object.freeze(result);
226
+ }
227
+ function createDOMAspectGuards(config, defaults) {
228
+ const result = {};
229
+ for (const aspect in defaults) {
230
+ const overrideValue = config[aspect];
231
+ const defaultValue = defaults[aspect];
232
+ switch (overrideValue) {
233
+ case null:
234
+ // remove the default
235
+ break;
236
+ case undefined:
237
+ // keep the default
238
+ result[aspect] = createDomSinkGuards(defaultValue, {});
239
+ break;
240
+ default:
241
+ // override the default
242
+ result[aspect] = createDomSinkGuards(overrideValue, defaultValue);
243
+ break;
244
+ }
245
+ }
246
+ // add any new aspect guards that were not overrides
247
+ for (const aspect in config) {
248
+ if (!(aspect in result)) {
249
+ result[aspect] = createDomSinkGuards(config[aspect], {});
250
+ }
251
+ }
252
+ return Object.freeze(result);
253
+ }
254
+ function createElementGuards(config, defaults) {
255
+ const result = {};
256
+ for (const tag in defaults) {
257
+ const overrideValue = config[tag];
258
+ const defaultValue = defaults[tag];
259
+ switch (overrideValue) {
260
+ case null:
261
+ // remove the default
262
+ break;
263
+ case undefined:
264
+ // keep the default
265
+ result[tag] = createDOMAspectGuards(overrideValue, {});
266
+ break;
267
+ default:
268
+ // override the default aspects
269
+ result[tag] = createDOMAspectGuards(overrideValue, defaultValue);
270
+ break;
271
+ }
272
+ }
273
+ // Add any new element guards that were not overrides
274
+ for (const tag in config) {
275
+ if (!(tag in result)) {
276
+ result[tag] = createDOMAspectGuards(config[tag], {});
277
+ }
278
+ }
279
+ return Object.freeze(result);
280
+ }
281
+ function createDOMGuards(config, defaults) {
282
+ return Object.freeze({
283
+ elements: config.elements
284
+ ? createElementGuards(config.elements, defaults.elements)
285
+ : defaults.elements,
286
+ aspects: config.aspects
287
+ ? createDOMAspectGuards(config.aspects, defaults.aspects)
288
+ : defaults.aspects,
289
+ });
290
+ }
291
+ function createTrustedType() {
292
+ const createHTML = html => html;
293
+ return globalThis.trustedTypes
294
+ ? globalThis.trustedTypes.createPolicy("fast-html", { createHTML })
295
+ : { createHTML };
296
+ }
297
+ function tryGuard(aspectGuards, tagName, aspect, aspectName, sink) {
298
+ const sinkGuards = aspectGuards[aspect];
299
+ if (sinkGuards) {
300
+ const guard = sinkGuards[aspectName];
301
+ if (guard) {
302
+ return guard(tagName, aspect, aspectName, sink);
303
+ }
304
+ }
305
+ }
306
+ const DOMPolicy = Object.freeze({
307
+ /**
308
+ * Creates a new DOM Policy object.
309
+ * @param options The options to use in creating the policy.
310
+ * @returns The newly created DOMPolicy.
311
+ */
312
+ create(options = {}) {
313
+ var _a, _b;
314
+ const trustedType = (_a = options.trustedType) !== null && _a !== void 0 ? _a : createTrustedType();
315
+ const guards = createDOMGuards((_b = options.guards) !== null && _b !== void 0 ? _b : {}, defaultDOMGuards);
316
+ return Object.freeze({
317
+ createHTML(value) {
318
+ return trustedType.createHTML(value);
319
+ },
320
+ protect(tagName, aspect, aspectName, sink) {
321
+ var _a;
322
+ // Check for element-specific guards.
323
+ const key = (tagName !== null && tagName !== void 0 ? tagName : "").toLowerCase();
324
+ const elementGuards = guards.elements[key];
325
+ if (elementGuards) {
326
+ const guard = tryGuard(elementGuards, tagName, aspect, aspectName, sink);
327
+ if (guard) {
328
+ return guard;
329
+ }
330
+ }
331
+ // Check for guards applicable to all nodes.
332
+ return ((_a = tryGuard(guards.aspects, tagName, aspect, aspectName, sink)) !== null && _a !== void 0 ? _a : sink);
333
+ },
334
+ });
335
+ },
336
+ });
337
+ export { DOMPolicy };
@@ -0,0 +1,117 @@
1
+ import { Updates } from "./observation/update-queue.js";
2
+ import "./interfaces.js";
3
+ import { FAST } from "./platform.js";
4
+ /**
5
+ * The type of HTML aspect to target.
6
+ * @public
7
+ */
8
+ export const DOMAspect = Object.freeze({
9
+ /**
10
+ * Not aspected.
11
+ */
12
+ none: 0,
13
+ /**
14
+ * An attribute.
15
+ */
16
+ attribute: 1,
17
+ /**
18
+ * A boolean attribute.
19
+ */
20
+ booleanAttribute: 2,
21
+ /**
22
+ * A property.
23
+ */
24
+ property: 3,
25
+ /**
26
+ * Content
27
+ */
28
+ content: 4,
29
+ /**
30
+ * A token list.
31
+ */
32
+ tokenList: 5,
33
+ /**
34
+ * An event.
35
+ */
36
+ event: 6,
37
+ });
38
+ const createHTML = html => html;
39
+ const fastTrustedType = globalThis.trustedTypes
40
+ ? globalThis.trustedTypes.createPolicy("fast-html", { createHTML })
41
+ : { createHTML };
42
+ let defaultPolicy = Object.freeze({
43
+ createHTML(value) {
44
+ return fastTrustedType.createHTML(value);
45
+ },
46
+ protect(tagName, aspect, aspectName, sink) {
47
+ return sink;
48
+ },
49
+ });
50
+ const fastPolicy = defaultPolicy;
51
+ /**
52
+ * Common DOM APIs.
53
+ * @public
54
+ */
55
+ export const DOM = Object.freeze({
56
+ /**
57
+ * @deprecated
58
+ * Use Updates.enqueue().
59
+ */
60
+ queueUpdate: Updates.enqueue,
61
+ /**
62
+ * @deprecated
63
+ * Use Updates.next()
64
+ */
65
+ nextUpdate: Updates.next,
66
+ /**
67
+ * @deprecated
68
+ * Use Updates.process()
69
+ */
70
+ processUpdates: Updates.process,
71
+ /**
72
+ * Gets the dom policy used by the templating system.
73
+ */
74
+ get policy() {
75
+ return defaultPolicy;
76
+ },
77
+ /**
78
+ * Sets the dom policy used by the templating system.
79
+ * @param policy - The policy to set.
80
+ * @remarks
81
+ * This API can only be called once, for security reasons. It should be
82
+ * called by the application developer at the start of their program.
83
+ */
84
+ setPolicy(value) {
85
+ if (defaultPolicy !== fastPolicy) {
86
+ throw FAST.error(1201 /* Message.onlySetDOMPolicyOnce */);
87
+ }
88
+ defaultPolicy = value;
89
+ },
90
+ /**
91
+ * Sets an attribute value on an element.
92
+ * @param element - The element to set the attribute value on.
93
+ * @param attributeName - The attribute name to set.
94
+ * @param value - The value of the attribute to set.
95
+ * @remarks
96
+ * If the value is `null` or `undefined`, the attribute is removed, otherwise
97
+ * it is set to the provided value using the standard `setAttribute` API.
98
+ */
99
+ setAttribute(element, attributeName, value) {
100
+ value === null || value === undefined
101
+ ? element.removeAttribute(attributeName)
102
+ : element.setAttribute(attributeName, value);
103
+ },
104
+ /**
105
+ * Sets a boolean attribute value.
106
+ * @param element - The element to set the boolean attribute value on.
107
+ * @param attributeName - The attribute name to set.
108
+ * @param value - The value of the attribute to set.
109
+ * @remarks
110
+ * If the value is true, the attribute is added; otherwise it is removed.
111
+ */
112
+ setBooleanAttribute(element, attributeName, value) {
113
+ value
114
+ ? element.setAttribute(attributeName, "")
115
+ : element.removeAttribute(attributeName);
116
+ },
117
+ });
package/dist/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./platform.js";
2
+ export * from "./dom.js";
2
3
  // Observation
3
4
  export * from "./observation/observable.js";
4
5
  export * from "./observation/notifier.js";
@@ -10,7 +11,6 @@ export * from "./styles/css.js";
10
11
  export * from "./styles/css-directive.js";
11
12
  export * from "./styles/host.js";
12
13
  // Templating
13
- export * from "./templating/dom.js";
14
14
  export * from "./templating/template.js";
15
15
  export * from "./templating/compiler.js";
16
16
  export { Markup, Parser } from "./templating/markup.js";
@@ -23,6 +23,7 @@ export * from "./templating/slotted.js";
23
23
  export * from "./templating/children.js";
24
24
  export * from "./templating/view.js";
25
25
  export * from "./templating/node-observation.js";
26
+ export * from "./templating/dangerous-html.js";
26
27
  // Components
27
28
  export * from "./components/fast-element.js";
28
29
  export * from "./components/fast-definitions.js";
@@ -1,3 +1,5 @@
1
- import "./polyfills.js";
2
1
  import "./debug.js";
2
+ import { DOMPolicy } from "./dom-policy.js";
3
+ import { DOM } from "./dom.js";
3
4
  export * from "./index.js";
5
+ DOM.setPolicy(DOMPolicy.create());
@@ -1,2 +1,4 @@
1
- import "./polyfills.js";
1
+ import { DOMPolicy } from "./dom-policy.js";
2
+ import { DOM } from "./dom.js";
2
3
  export * from "./index.js";
4
+ DOM.setPolicy(DOMPolicy.create());
@@ -1,4 +1,4 @@
1
- import { isFunction, isString, } from "../interfaces.js";
1
+ import { isFunction, isString, noop, } from "../interfaces.js";
2
2
  import { createMetadataLocator, FAST } from "../platform.js";
3
3
  import { Updates } from "./update-queue.js";
4
4
  import { PropertyChangeNotifier, SubscriberSet } from "./notifier.js";
@@ -79,6 +79,10 @@ export const Observable = FAST.getById(2 /* KernelServiceId.observable */, () =>
79
79
  this.propertyName = void 0;
80
80
  this.notifier = void 0;
81
81
  this.next = void 0;
82
+ /**
83
+ * Opts out of JSON stringification.
84
+ */
85
+ this.toJSON = noop;
82
86
  }
83
87
  setMode(isAsync) {
84
88
  this.isAsync = this.needsQueue = isAsync;
@@ -1,5 +1,5 @@
1
1
  import "./polyfills.js";
2
- // ensure FAST global - duplicated in polyfills.ts and debug.ts
2
+ // ensure FAST global - duplicated debug.ts
3
3
  const propConfig = {
4
4
  configurable: false,
5
5
  enumerable: false,
@@ -1,10 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1
2
  (function ensureGlobalThis() {
2
3
  if (typeof globalThis !== "undefined") {
3
4
  // We're running in a modern environment.
4
5
  return;
5
6
  }
7
+ // @ts-ignore
6
8
  if (typeof global !== "undefined") {
7
9
  // We're running in NodeJS
10
+ // @ts-ignore
8
11
  global.globalThis = global;
9
12
  }
10
13
  else if (typeof self !== "undefined") {
@@ -22,10 +25,3 @@
22
25
  result.globalThis = result;
23
26
  }
24
27
  })();
25
- // API-only Polyfill for trustedTypes
26
- if (!globalThis.trustedTypes) {
27
- globalThis.trustedTypes = {
28
- createPolicy: (n, r) => r,
29
- };
30
- }
31
- export {};
@@ -1,4 +1,4 @@
1
- import { isString } from "../interfaces.js";
1
+ import { isString, noop } from "../interfaces.js";
2
2
  import { Binding } from "./html-directive.js";
3
3
  const subscribers = Object.create(null);
4
4
  export const Signal = Object.freeze({
@@ -41,6 +41,11 @@ class SignalObserver {
41
41
  this.dataBinding = dataBinding;
42
42
  this.subscriber = subscriber;
43
43
  this.isNotBound = true;
44
+ /**
45
+ * Opts out of JSON stringification.
46
+ * @internal
47
+ */
48
+ this.toJSON = noop;
44
49
  }
45
50
  bind(controller) {
46
51
  if (this.isNotBound) {
@@ -73,11 +78,12 @@ class SignalBinding extends Binding {
73
78
  * Creates a signal binding configuration with the supplied options.
74
79
  * @param expression - The binding to refresh when signaled.
75
80
  * @param options - The signal name or a binding to use to retrieve the signal name.
81
+ * @param policy - The security policy to associate with th binding.
76
82
  * @returns A binding configuration.
77
83
  * @public
78
84
  */
79
- export function signal(expression, options) {
80
- const binding = new SignalBinding(expression);
85
+ export function signal(expression, options, policy) {
86
+ const binding = new SignalBinding(expression, policy);
81
87
  binding.options = options;
82
88
  return binding;
83
89
  }
@@ -1,4 +1,4 @@
1
- import { isString } from "../interfaces.js";
1
+ import { isString, noop } from "../interfaces.js";
2
2
  import { Observable, } from "../observation/observable.js";
3
3
  import { FAST } from "../platform.js";
4
4
  import { Binding } from "./html-directive.js";
@@ -25,6 +25,11 @@ class TwoWayObserver {
25
25
  this.subscriber = subscriber;
26
26
  this.dataBinding = dataBinding;
27
27
  this.isNotBound = true;
28
+ /**
29
+ * Opts out of JSON stringification.
30
+ * @internal
31
+ */
32
+ this.toJSON = noop;
28
33
  this.notifier = Observable.binding(dataBinding.evaluate, this, dataBinding.isVolatile);
29
34
  }
30
35
  bind(controller) {
@@ -83,11 +88,12 @@ class TwoWayBinding extends Binding {
83
88
  * Creates a default binding.
84
89
  * @param expression - The binding to refresh when changed.
85
90
  * @param optionsOrChangeEvent - The binding options or the name of the change event to use.
91
+ * @param policy - The security policy to associate with the binding.
86
92
  * @param isBindingVolatile - Indicates whether the binding is volatile or not.
87
93
  * @returns A binding.
88
94
  * @public
89
95
  */
90
- export function twoWay(expression, optionsOrChangeEvent, isBindingVolatile = Observable.isVolatileBinding(expression)) {
96
+ export function twoWay(expression, optionsOrChangeEvent, policy, isBindingVolatile = Observable.isVolatileBinding(expression)) {
91
97
  if (isString(optionsOrChangeEvent)) {
92
98
  optionsOrChangeEvent = { changeEvent: optionsOrChangeEvent };
93
99
  }
@@ -97,7 +103,7 @@ export function twoWay(expression, optionsOrChangeEvent, isBindingVolatile = Obs
97
103
  else if (!optionsOrChangeEvent.fromView) {
98
104
  optionsOrChangeEvent.fromView = defaultOptions.fromView;
99
105
  }
100
- const binding = new TwoWayBinding(expression, isBindingVolatile);
106
+ const binding = new TwoWayBinding(expression, policy, isBindingVolatile);
101
107
  binding.options = optionsOrChangeEvent;
102
108
  return binding;
103
109
  }