@microsoft/fast-element 2.0.0-beta.12 → 2.0.0-beta.14

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 CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@microsoft/fast-element",
3
3
  "entries": [
4
+ {
5
+ "date": "Fri, 14 Oct 2022 18:26:11 GMT",
6
+ "tag": "@microsoft/fast-element_v2.0.0-beta.14",
7
+ "version": "2.0.0-beta.14",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "roeisenb@microsoft.com",
12
+ "package": "@microsoft/fast-element",
13
+ "commit": "19f1ae727e2ff6e629d2b134fc045a81d83caaed",
14
+ "comment": "fix: tokenList bindings track adds and removes from multiple sources"
15
+ },
16
+ {
17
+ "author": "roeisenb@microsoft.com",
18
+ "package": "@microsoft/fast-element",
19
+ "commit": "0248fa906f986d6b0cbdeb26cf388742e871449e",
20
+ "comment": "refactor: remove duplication and re-organize binding behavior logic"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Mon, 10 Oct 2022 20:28:02 GMT",
27
+ "tag": "@microsoft/fast-element_v2.0.0-beta.13",
28
+ "version": "2.0.0-beta.13",
29
+ "comments": {
30
+ "prerelease": [
31
+ {
32
+ "author": "roeisenb@microsoft.com",
33
+ "package": "@microsoft/fast-element",
34
+ "commit": "fed5e806e44da9d10916d9d765fb7f35ed300a3f",
35
+ "comment": "fix: prevent event callbacks when controller is not bound"
36
+ }
37
+ ]
38
+ }
39
+ },
4
40
  {
5
41
  "date": "Thu, 06 Oct 2022 23:21:20 GMT",
6
42
  "tag": "@microsoft/fast-element_v2.0.0-beta.12",
package/CHANGELOG.md CHANGED
@@ -1,9 +1,26 @@
1
1
  # Change Log - @microsoft/fast-element
2
2
 
3
- This log was last generated on Thu, 06 Oct 2022 23:21:20 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 14 Oct 2022 18:26:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.0.0-beta.14
8
+
9
+ Fri, 14 Oct 2022 18:26:11 GMT
10
+
11
+ ### Changes
12
+
13
+ - fix: tokenList bindings track adds and removes from multiple sources (roeisenb@microsoft.com)
14
+ - refactor: remove duplication and re-organize binding behavior logic (roeisenb@microsoft.com)
15
+
16
+ ## 2.0.0-beta.13
17
+
18
+ Mon, 10 Oct 2022 20:28:02 GMT
19
+
20
+ ### Changes
21
+
22
+ - fix: prevent event callbacks when controller is not bound (roeisenb@microsoft.com)
23
+
7
24
  ## 2.0.0-beta.12
8
25
 
9
26
  Thu, 06 Oct 2022 23:21:20 GMT
@@ -80,13 +80,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
80
80
  */
81
81
  createBehavior(): ViewBehavior;
82
82
  /** @internal */
83
- bindDefault(controller: ViewController): void;
84
- /** @internal */
85
- bind: (controller: ViewController) => void;
86
- /** @internal */
87
- bindContent(controller: ViewController): void;
88
- /** @internal */
89
- bindEvent(controller: ViewController): void;
83
+ bind(controller: ViewController): void;
90
84
  /** @internal */
91
85
  unbind(controller: ViewController): void;
92
86
  /** @internal */
@@ -96,27 +90,27 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
96
90
  }
97
91
  /**
98
92
  * Creates an standard binding.
99
- * @param binding - The binding to refresh when changed.
93
+ * @param expression - The binding to refresh when changed.
100
94
  * @param isVolatile - Indicates whether the binding is volatile or not.
101
95
  * @returns A binding configuration.
102
96
  * @public
103
97
  */
104
- export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
98
+ export declare function bind<T = any>(expression: Expression<T>, isVolatile?: boolean): Binding<T>;
105
99
  /**
106
100
  * Creates a one time binding
107
- * @param binding - The binding to refresh when signaled.
101
+ * @param expression - The binding to refresh when signaled.
108
102
  * @returns A binding configuration.
109
103
  * @public
110
104
  */
111
- export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
105
+ export declare function oneTime<T = any>(expression: Expression<T>): Binding<T>;
112
106
  /**
113
107
  * Creates an event listener binding.
114
- * @param binding - The binding to invoke when the event is raised.
108
+ * @param expression - The binding to invoke when the event is raised.
115
109
  * @param options - Event listener options.
116
110
  * @returns A binding configuration.
117
111
  * @public
118
112
  */
119
- export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
113
+ export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
120
114
  /**
121
115
  * Normalizes the input value into a binding.
122
116
  * @param value - The value to create the default binding for.
@@ -1,4 +1,13 @@
1
- import { ExecutionContext } from "../index.js";
1
+ import { ExecutionContext, ViewBehavior, ViewBehaviorTargets } from "../index.js";
2
2
  export declare const Fake: Readonly<{
3
3
  executionContext<TParent = any>(parent?: TParent | undefined, parentContext?: ExecutionContext<TParent> | undefined): ExecutionContext<TParent>;
4
+ viewController<TSource = any, TParent_1 = any>(targets?: ViewBehaviorTargets, ...behaviors: ViewBehavior<TSource, TParent_1>[]): {
5
+ isBound: boolean;
6
+ context: ExecutionContext<TParent_1>;
7
+ onUnbind(object: any): void;
8
+ source: TSource;
9
+ targets: ViewBehaviorTargets;
10
+ bind(source: TSource, context?: ExecutionContext<TParent_1>): void;
11
+ unbind(): void;
12
+ };
4
13
  }>;
@@ -88,9 +88,9 @@ function updateContent(target, aspect, value, controller) {
88
88
  function updateTokenList(target, aspect, value) {
89
89
  var _a;
90
90
  const lookup = `${this.id}-t`;
91
- const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = { c: 0, v: Object.create(null) });
92
- const versions = state.v;
93
- let currentVersion = state.c;
91
+ const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = { v: 0, cv: Object.create(null) });
92
+ const classVersions = state.cv;
93
+ let version = state.v;
94
94
  const tokenList = target[aspect];
95
95
  // Add the classes, tracking the version at which they were added.
96
96
  if (value !== null && value !== undefined && value.length) {
@@ -100,19 +100,19 @@ function updateTokenList(target, aspect, value) {
100
100
  if (currentName === "") {
101
101
  continue;
102
102
  }
103
- versions[currentName] = currentVersion;
103
+ classVersions[currentName] = version;
104
104
  tokenList.add(currentName);
105
105
  }
106
106
  }
107
- state.v = currentVersion + 1;
107
+ state.v = version + 1;
108
108
  // If this is the first call to add classes, there's no need to remove old ones.
109
- if (currentVersion === 0) {
109
+ if (version === 0) {
110
110
  return;
111
111
  }
112
112
  // Remove classes from the previous version.
113
- currentVersion -= 1;
114
- for (const name in versions) {
115
- if (versions[name] === currentVersion) {
113
+ version -= 1;
114
+ for (const name in classVersions) {
115
+ if (classVersions[name] === version) {
116
116
  tokenList.remove(name);
117
117
  }
118
118
  }
@@ -139,8 +139,6 @@ export class HTMLBindingDirective {
139
139
  * The type of aspect to target.
140
140
  */
141
141
  this.aspectType = Aspect.content;
142
- /** @internal */
143
- this.bind = this.bindDefault;
144
142
  this.data = `${this.id}-d`;
145
143
  }
146
144
  /**
@@ -169,14 +167,12 @@ export class HTMLBindingDirective {
169
167
  this.updateTarget = setProperty;
170
168
  break;
171
169
  case 4:
172
- this.bind = this.bindContent;
173
170
  this.updateTarget = updateContent;
174
171
  break;
175
172
  case 5:
176
173
  this.updateTarget = updateTokenList;
177
174
  break;
178
175
  case 6:
179
- this.bind = this.bindEvent;
180
176
  this.updateTarget = eventTarget;
181
177
  break;
182
178
  default:
@@ -186,29 +182,26 @@ export class HTMLBindingDirective {
186
182
  return this;
187
183
  }
188
184
  /** @internal */
189
- bindDefault(controller) {
185
+ bind(controller) {
190
186
  var _a;
191
187
  const target = controller.targets[this.nodeId];
192
- const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
193
- observer.target = target;
194
- observer.controller = controller;
195
- this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
196
- if (this.updateTarget === updateContent) {
197
- controller.onUnbind(this);
188
+ switch (this.updateTarget) {
189
+ case eventTarget:
190
+ target[this.data] = controller;
191
+ target.addEventListener(this.targetAspect, this, this.dataBinding.options);
192
+ break;
193
+ case updateContent:
194
+ controller.onUnbind(this);
195
+ // intentional fall through
196
+ default:
197
+ const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
198
+ observer.target = target;
199
+ observer.controller = controller;
200
+ this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
201
+ break;
198
202
  }
199
203
  }
200
204
  /** @internal */
201
- bindContent(controller) {
202
- this.bindDefault(controller);
203
- controller.onUnbind(this);
204
- }
205
- /** @internal */
206
- bindEvent(controller) {
207
- const target = controller.targets[this.nodeId];
208
- target[this.data] = controller;
209
- target.addEventListener(this.targetAspect, this, this.dataBinding.options);
210
- }
211
- /** @internal */
212
205
  unbind(controller) {
213
206
  const target = controller.targets[this.nodeId];
214
207
  const view = target.$fastView;
@@ -219,13 +212,14 @@ export class HTMLBindingDirective {
219
212
  }
220
213
  /** @internal */
221
214
  handleEvent(event) {
222
- const target = event.currentTarget;
223
- ExecutionContext.setEvent(event);
224
- const controller = target[this.data];
225
- const result = this.dataBinding.evaluate(controller.source, controller.context);
226
- ExecutionContext.setEvent(null);
227
- if (result !== true) {
228
- event.preventDefault();
215
+ const controller = event.currentTarget[this.data];
216
+ if (controller.isBound) {
217
+ ExecutionContext.setEvent(event);
218
+ const result = this.dataBinding.evaluate(controller.source, controller.context);
219
+ ExecutionContext.setEvent(null);
220
+ if (result !== true) {
221
+ event.preventDefault();
222
+ }
229
223
  }
230
224
  }
231
225
  /** @internal */
@@ -238,32 +232,32 @@ export class HTMLBindingDirective {
238
232
  HTMLDirective.define(HTMLBindingDirective, { aspected: true });
239
233
  /**
240
234
  * Creates an standard binding.
241
- * @param binding - The binding to refresh when changed.
235
+ * @param expression - The binding to refresh when changed.
242
236
  * @param isVolatile - Indicates whether the binding is volatile or not.
243
237
  * @returns A binding configuration.
244
238
  * @public
245
239
  */
246
- export function bind(binding, isVolatile = Observable.isVolatileBinding(binding)) {
247
- return new OnChangeBinding(binding, isVolatile);
240
+ export function bind(expression, isVolatile = Observable.isVolatileBinding(expression)) {
241
+ return new OnChangeBinding(expression, isVolatile);
248
242
  }
249
243
  /**
250
244
  * Creates a one time binding
251
- * @param binding - The binding to refresh when signaled.
245
+ * @param expression - The binding to refresh when signaled.
252
246
  * @returns A binding configuration.
253
247
  * @public
254
248
  */
255
- export function oneTime(binding) {
256
- return new OneTimeBinding(binding);
249
+ export function oneTime(expression) {
250
+ return new OneTimeBinding(expression);
257
251
  }
258
252
  /**
259
253
  * Creates an event listener binding.
260
- * @param binding - The binding to invoke when the event is raised.
254
+ * @param expression - The binding to invoke when the event is raised.
261
255
  * @param options - Event listener options.
262
256
  * @returns A binding configuration.
263
257
  * @public
264
258
  */
265
- export function listener(binding, options) {
266
- const config = new OnChangeBinding(binding, false);
259
+ export function listener(expression, options) {
260
+ const config = new OnChangeBinding(expression, false);
267
261
  config.options = options;
268
262
  return config;
269
263
  }
@@ -1,4 +1,4 @@
1
- import { ExecutionContext } from "../index.js";
1
+ import { ExecutionContext, } from "../index.js";
2
2
  export const Fake = Object.freeze({
3
3
  executionContext(parent, parentContext) {
4
4
  return {
@@ -73,4 +73,33 @@ export const Fake = Object.freeze({
73
73
  },
74
74
  };
75
75
  },
76
+ viewController(targets = {}, ...behaviors) {
77
+ const unbindables = new Set();
78
+ return {
79
+ isBound: false,
80
+ context: null,
81
+ onUnbind(object) {
82
+ unbindables.add(object);
83
+ },
84
+ source: null,
85
+ targets,
86
+ bind(source, context = Fake.executionContext()) {
87
+ if (this.isBound) {
88
+ return;
89
+ }
90
+ this.source = source;
91
+ this.context = context;
92
+ behaviors.forEach(x => x.bind(this));
93
+ this.isBound = true;
94
+ },
95
+ unbind() {
96
+ if (this.isBound) {
97
+ unbindables.forEach(x => x.unbind(this));
98
+ this.source = null;
99
+ this.context = null;
100
+ this.isBound = false;
101
+ }
102
+ },
103
+ };
104
+ },
76
105
  });
@@ -1442,7 +1442,7 @@
1442
1442
  {
1443
1443
  "kind": "Function",
1444
1444
  "canonicalReference": "@microsoft/fast-element!bind:function(1)",
1445
- "docComment": "/**\n * Creates an standard binding.\n *\n * @param binding - The binding to refresh when changed.\n *\n * @param isVolatile - Indicates whether the binding is volatile or not.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
1445
+ "docComment": "/**\n * Creates an standard binding.\n *\n * @param expression - The binding to refresh when changed.\n *\n * @param isVolatile - Indicates whether the binding is volatile or not.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
1446
1446
  "excerptTokens": [
1447
1447
  {
1448
1448
  "kind": "Content",
@@ -1454,7 +1454,7 @@
1454
1454
  },
1455
1455
  {
1456
1456
  "kind": "Content",
1457
- "text": ">(binding: "
1457
+ "text": ">(expression: "
1458
1458
  },
1459
1459
  {
1460
1460
  "kind": "Reference",
@@ -1499,7 +1499,7 @@
1499
1499
  "overloadIndex": 1,
1500
1500
  "parameters": [
1501
1501
  {
1502
- "parameterName": "binding",
1502
+ "parameterName": "expression",
1503
1503
  "parameterTypeTokenRange": {
1504
1504
  "startIndex": 3,
1505
1505
  "endIndex": 5
@@ -10141,7 +10141,7 @@
10141
10141
  {
10142
10142
  "kind": "Function",
10143
10143
  "canonicalReference": "@microsoft/fast-element!listener:function(1)",
10144
- "docComment": "/**\n * Creates an event listener binding.\n *\n * @param binding - The binding to invoke when the event is raised.\n *\n * @param options - Event listener options.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
10144
+ "docComment": "/**\n * Creates an event listener binding.\n *\n * @param expression - The binding to invoke when the event is raised.\n *\n * @param options - Event listener options.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
10145
10145
  "excerptTokens": [
10146
10146
  {
10147
10147
  "kind": "Content",
@@ -10153,7 +10153,7 @@
10153
10153
  },
10154
10154
  {
10155
10155
  "kind": "Content",
10156
- "text": ">(binding: "
10156
+ "text": ">(expression: "
10157
10157
  },
10158
10158
  {
10159
10159
  "kind": "Reference",
@@ -10199,7 +10199,7 @@
10199
10199
  "overloadIndex": 1,
10200
10200
  "parameters": [
10201
10201
  {
10202
- "parameterName": "binding",
10202
+ "parameterName": "expression",
10203
10203
  "parameterTypeTokenRange": {
10204
10204
  "startIndex": 3,
10205
10205
  "endIndex": 5
@@ -11397,7 +11397,7 @@
11397
11397
  {
11398
11398
  "kind": "Function",
11399
11399
  "canonicalReference": "@microsoft/fast-element!oneTime:function(1)",
11400
- "docComment": "/**\n * Creates a one time binding\n *\n * @param binding - The binding to refresh when signaled.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
11400
+ "docComment": "/**\n * Creates a one time binding\n *\n * @param expression - The binding to refresh when signaled.\n *\n * @returns A binding configuration.\n *\n * @public\n */\n",
11401
11401
  "excerptTokens": [
11402
11402
  {
11403
11403
  "kind": "Content",
@@ -11409,7 +11409,7 @@
11409
11409
  },
11410
11410
  {
11411
11411
  "kind": "Content",
11412
- "text": ">(binding: "
11412
+ "text": ">(expression: "
11413
11413
  },
11414
11414
  {
11415
11415
  "kind": "Reference",
@@ -11446,7 +11446,7 @@
11446
11446
  "overloadIndex": 1,
11447
11447
  "parameters": [
11448
11448
  {
11449
- "parameterName": "binding",
11449
+ "parameterName": "expression",
11450
11450
  "parameterTypeTokenRange": {
11451
11451
  "startIndex": 3,
11452
11452
  "endIndex": 5
@@ -258,12 +258,12 @@ export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "f
258
258
 
259
259
  /**
260
260
  * Creates an standard binding.
261
- * @param binding - The binding to refresh when changed.
261
+ * @param expression - The binding to refresh when changed.
262
262
  * @param isVolatile - Indicates whether the binding is volatile or not.
263
263
  * @returns A binding configuration.
264
264
  * @public
265
265
  */
266
- export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
266
+ export declare function bind<T = any>(expression: Expression<T>, isVolatile?: boolean): Binding<T>;
267
267
 
268
268
  /**
269
269
  * Captures a binding expression along with related information and capabilities.
@@ -1295,10 +1295,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1295
1295
  * Creates a behavior.
1296
1296
  */
1297
1297
  createBehavior(): ViewBehavior;
1298
- /* Excluded from this release type: bindDefault */
1299
1298
  /* Excluded from this release type: bind */
1300
- /* Excluded from this release type: bindContent */
1301
- /* Excluded from this release type: bindEvent */
1302
1299
  /* Excluded from this release type: unbind */
1303
1300
  /* Excluded from this release type: handleEvent */
1304
1301
  /* Excluded from this release type: handleChange */
@@ -1524,12 +1521,12 @@ export declare function lengthOf<T>(array: readonly T[]): number;
1524
1521
 
1525
1522
  /**
1526
1523
  * Creates an event listener binding.
1527
- * @param binding - The binding to invoke when the event is raised.
1524
+ * @param expression - The binding to invoke when the event is raised.
1528
1525
  * @param options - Event listener options.
1529
1526
  * @returns A binding configuration.
1530
1527
  * @public
1531
1528
  */
1532
- export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
1529
+ export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
1533
1530
 
1534
1531
  /**
1535
1532
  * Common APIs related to markup generation.
@@ -1776,11 +1773,11 @@ export declare interface ObservationRecord {
1776
1773
 
1777
1774
  /**
1778
1775
  * Creates a one time binding
1779
- * @param binding - The binding to refresh when signaled.
1776
+ * @param expression - The binding to refresh when signaled.
1780
1777
  * @returns A binding configuration.
1781
1778
  * @public
1782
1779
  */
1783
- export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
1780
+ export declare function oneTime<T = any>(expression: Expression<T>): Binding<T>;
1784
1781
 
1785
1782
  /**
1786
1783
  * Common APIs related to content parsing.
@@ -1963,9 +1963,9 @@ function updateContent(target, aspect, value, controller) {
1963
1963
  function updateTokenList(target, aspect, value) {
1964
1964
  var _a;
1965
1965
  const lookup = `${this.id}-t`;
1966
- const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = { c: 0, v: Object.create(null) });
1967
- const versions = state.v;
1968
- let currentVersion = state.c;
1966
+ const state = (_a = target[lookup]) !== null && _a !== void 0 ? _a : (target[lookup] = { v: 0, cv: Object.create(null) });
1967
+ const classVersions = state.cv;
1968
+ let version = state.v;
1969
1969
  const tokenList = target[aspect];
1970
1970
  // Add the classes, tracking the version at which they were added.
1971
1971
  if (value !== null && value !== undefined && value.length) {
@@ -1975,19 +1975,19 @@ function updateTokenList(target, aspect, value) {
1975
1975
  if (currentName === "") {
1976
1976
  continue;
1977
1977
  }
1978
- versions[currentName] = currentVersion;
1978
+ classVersions[currentName] = version;
1979
1979
  tokenList.add(currentName);
1980
1980
  }
1981
1981
  }
1982
- state.v = currentVersion + 1;
1982
+ state.v = version + 1;
1983
1983
  // If this is the first call to add classes, there's no need to remove old ones.
1984
- if (currentVersion === 0) {
1984
+ if (version === 0) {
1985
1985
  return;
1986
1986
  }
1987
1987
  // Remove classes from the previous version.
1988
- currentVersion -= 1;
1989
- for (const name in versions) {
1990
- if (versions[name] === currentVersion) {
1988
+ version -= 1;
1989
+ for (const name in classVersions) {
1990
+ if (classVersions[name] === version) {
1991
1991
  tokenList.remove(name);
1992
1992
  }
1993
1993
  }
@@ -2014,8 +2014,6 @@ class HTMLBindingDirective {
2014
2014
  * The type of aspect to target.
2015
2015
  */
2016
2016
  this.aspectType = Aspect.content;
2017
- /** @internal */
2018
- this.bind = this.bindDefault;
2019
2017
  this.data = `${this.id}-d`;
2020
2018
  }
2021
2019
  /**
@@ -2044,14 +2042,12 @@ class HTMLBindingDirective {
2044
2042
  this.updateTarget = setProperty;
2045
2043
  break;
2046
2044
  case 4:
2047
- this.bind = this.bindContent;
2048
2045
  this.updateTarget = updateContent;
2049
2046
  break;
2050
2047
  case 5:
2051
2048
  this.updateTarget = updateTokenList;
2052
2049
  break;
2053
2050
  case 6:
2054
- this.bind = this.bindEvent;
2055
2051
  this.updateTarget = eventTarget;
2056
2052
  break;
2057
2053
  default:
@@ -2061,29 +2057,26 @@ class HTMLBindingDirective {
2061
2057
  return this;
2062
2058
  }
2063
2059
  /** @internal */
2064
- bindDefault(controller) {
2060
+ bind(controller) {
2065
2061
  var _a;
2066
2062
  const target = controller.targets[this.nodeId];
2067
- const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
2068
- observer.target = target;
2069
- observer.controller = controller;
2070
- this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
2071
- if (this.updateTarget === updateContent) {
2072
- controller.onUnbind(this);
2063
+ switch (this.updateTarget) {
2064
+ case eventTarget:
2065
+ target[this.data] = controller;
2066
+ target.addEventListener(this.targetAspect, this, this.dataBinding.options);
2067
+ break;
2068
+ case updateContent:
2069
+ controller.onUnbind(this);
2070
+ // intentional fall through
2071
+ default:
2072
+ const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
2073
+ observer.target = target;
2074
+ observer.controller = controller;
2075
+ this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
2076
+ break;
2073
2077
  }
2074
2078
  }
2075
2079
  /** @internal */
2076
- bindContent(controller) {
2077
- this.bindDefault(controller);
2078
- controller.onUnbind(this);
2079
- }
2080
- /** @internal */
2081
- bindEvent(controller) {
2082
- const target = controller.targets[this.nodeId];
2083
- target[this.data] = controller;
2084
- target.addEventListener(this.targetAspect, this, this.dataBinding.options);
2085
- }
2086
- /** @internal */
2087
2080
  unbind(controller) {
2088
2081
  const target = controller.targets[this.nodeId];
2089
2082
  const view = target.$fastView;
@@ -2094,13 +2087,14 @@ class HTMLBindingDirective {
2094
2087
  }
2095
2088
  /** @internal */
2096
2089
  handleEvent(event) {
2097
- const target = event.currentTarget;
2098
- ExecutionContext.setEvent(event);
2099
- const controller = target[this.data];
2100
- const result = this.dataBinding.evaluate(controller.source, controller.context);
2101
- ExecutionContext.setEvent(null);
2102
- if (result !== true) {
2103
- event.preventDefault();
2090
+ const controller = event.currentTarget[this.data];
2091
+ if (controller.isBound) {
2092
+ ExecutionContext.setEvent(event);
2093
+ const result = this.dataBinding.evaluate(controller.source, controller.context);
2094
+ ExecutionContext.setEvent(null);
2095
+ if (result !== true) {
2096
+ event.preventDefault();
2097
+ }
2104
2098
  }
2105
2099
  }
2106
2100
  /** @internal */
@@ -2113,32 +2107,32 @@ class HTMLBindingDirective {
2113
2107
  HTMLDirective.define(HTMLBindingDirective, { aspected: true });
2114
2108
  /**
2115
2109
  * Creates an standard binding.
2116
- * @param binding - The binding to refresh when changed.
2110
+ * @param expression - The binding to refresh when changed.
2117
2111
  * @param isVolatile - Indicates whether the binding is volatile or not.
2118
2112
  * @returns A binding configuration.
2119
2113
  * @public
2120
2114
  */
2121
- function bind(binding, isVolatile = Observable.isVolatileBinding(binding)) {
2122
- return new OnChangeBinding(binding, isVolatile);
2115
+ function bind(expression, isVolatile = Observable.isVolatileBinding(expression)) {
2116
+ return new OnChangeBinding(expression, isVolatile);
2123
2117
  }
2124
2118
  /**
2125
2119
  * Creates a one time binding
2126
- * @param binding - The binding to refresh when signaled.
2120
+ * @param expression - The binding to refresh when signaled.
2127
2121
  * @returns A binding configuration.
2128
2122
  * @public
2129
2123
  */
2130
- function oneTime(binding) {
2131
- return new OneTimeBinding(binding);
2124
+ function oneTime(expression) {
2125
+ return new OneTimeBinding(expression);
2132
2126
  }
2133
2127
  /**
2134
2128
  * Creates an event listener binding.
2135
- * @param binding - The binding to invoke when the event is raised.
2129
+ * @param expression - The binding to invoke when the event is raised.
2136
2130
  * @param options - Event listener options.
2137
2131
  * @returns A binding configuration.
2138
2132
  * @public
2139
2133
  */
2140
- function listener(binding, options) {
2141
- const config = new OnChangeBinding(binding, false);
2134
+ function listener(expression, options) {
2135
+ const config = new OnChangeBinding(expression, false);
2142
2136
  config.options = options;
2143
2137
  return config;
2144
2138
  }