@microsoft/fast-element 1.10.5 → 2.0.0-beta.10

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 (122) hide show
  1. package/.eslintrc.json +1 -12
  2. package/CHANGELOG.json +629 -6
  3. package/CHANGELOG.md +152 -5
  4. package/dist/dts/components/attributes.d.ts +14 -1
  5. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
  6. package/dist/dts/components/fast-definitions.d.ts +51 -11
  7. package/dist/dts/components/fast-element.d.ts +18 -23
  8. package/dist/dts/context.d.ts +157 -0
  9. package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
  10. package/dist/dts/di/di.d.ts +899 -0
  11. package/dist/dts/index.d.ts +17 -16
  12. package/dist/dts/index.debug.d.ts +2 -0
  13. package/dist/dts/index.rollup.d.ts +2 -0
  14. package/dist/dts/index.rollup.debug.d.ts +3 -0
  15. package/dist/dts/interfaces.d.ts +176 -0
  16. package/dist/dts/metadata.d.ts +25 -0
  17. package/dist/dts/observation/arrays.d.ts +207 -0
  18. package/dist/dts/observation/notifier.d.ts +18 -18
  19. package/dist/dts/observation/observable.d.ts +117 -34
  20. package/dist/dts/observation/update-queue.d.ts +40 -0
  21. package/dist/dts/pending-task.d.ts +20 -0
  22. package/dist/dts/platform.d.ts +23 -66
  23. package/dist/dts/polyfills.d.ts +8 -0
  24. package/dist/dts/state/exports.d.ts +3 -0
  25. package/dist/dts/state/reactive.d.ts +8 -0
  26. package/dist/dts/state/state.d.ts +141 -0
  27. package/dist/dts/state/visitor.d.ts +6 -0
  28. package/dist/dts/state/watch.d.ts +10 -0
  29. package/dist/dts/styles/css-directive.d.ts +44 -6
  30. package/dist/dts/styles/css.d.ts +19 -3
  31. package/dist/dts/styles/element-styles.d.ts +49 -63
  32. package/dist/dts/styles/host.d.ts +68 -0
  33. package/dist/dts/templating/binding-signal.d.ts +21 -0
  34. package/dist/dts/templating/binding-two-way.d.ts +39 -0
  35. package/dist/dts/templating/binding.d.ts +101 -70
  36. package/dist/dts/templating/children.d.ts +18 -15
  37. package/dist/dts/templating/compiler.d.ts +46 -28
  38. package/dist/dts/templating/dom.d.ts +41 -0
  39. package/dist/dts/templating/html-directive.d.ts +239 -45
  40. package/dist/dts/templating/markup.d.ts +48 -0
  41. package/dist/dts/templating/node-observation.d.ts +45 -30
  42. package/dist/dts/templating/ref.d.ts +6 -20
  43. package/dist/dts/templating/render.d.ts +272 -0
  44. package/dist/dts/templating/repeat.d.ts +36 -33
  45. package/dist/dts/templating/slotted.d.ts +13 -14
  46. package/dist/dts/templating/template.d.ts +28 -22
  47. package/dist/dts/templating/view.d.ts +82 -24
  48. package/dist/dts/templating/when.d.ts +3 -3
  49. package/dist/dts/testing/exports.d.ts +3 -0
  50. package/dist/dts/testing/fakes.d.ts +4 -0
  51. package/dist/dts/testing/fixture.d.ts +84 -0
  52. package/dist/dts/testing/timeout.d.ts +7 -0
  53. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
  54. package/dist/dts/utilities.d.ts +22 -0
  55. package/dist/esm/components/attributes.js +38 -28
  56. package/dist/esm/components/{controller.js → element-controller.js} +150 -140
  57. package/dist/esm/components/fast-definitions.js +48 -46
  58. package/dist/esm/components/fast-element.js +31 -12
  59. package/dist/esm/context.js +163 -0
  60. package/dist/esm/debug.js +61 -0
  61. package/dist/esm/di/di.js +1435 -0
  62. package/dist/esm/index.debug.js +2 -0
  63. package/dist/esm/index.js +20 -14
  64. package/dist/esm/index.rollup.debug.js +3 -0
  65. package/dist/esm/index.rollup.js +2 -0
  66. package/dist/esm/interfaces.js +12 -1
  67. package/dist/esm/metadata.js +60 -0
  68. package/dist/esm/observation/arrays.js +570 -0
  69. package/dist/esm/observation/notifier.js +27 -35
  70. package/dist/esm/observation/observable.js +116 -149
  71. package/dist/esm/observation/update-queue.js +67 -0
  72. package/dist/esm/pending-task.js +16 -0
  73. package/dist/esm/platform.js +60 -42
  74. package/dist/esm/polyfills.js +85 -0
  75. package/dist/esm/state/exports.js +3 -0
  76. package/dist/esm/state/reactive.js +34 -0
  77. package/dist/esm/state/state.js +148 -0
  78. package/dist/esm/state/visitor.js +28 -0
  79. package/dist/esm/state/watch.js +36 -0
  80. package/dist/esm/styles/css-directive.js +29 -13
  81. package/dist/esm/styles/css.js +29 -42
  82. package/dist/esm/styles/element-styles.js +79 -104
  83. package/dist/esm/styles/host.js +1 -0
  84. package/dist/esm/templating/binding-signal.js +83 -0
  85. package/dist/esm/templating/binding-two-way.js +103 -0
  86. package/dist/esm/templating/binding.js +189 -159
  87. package/dist/esm/templating/children.js +33 -23
  88. package/dist/esm/templating/compiler.js +258 -152
  89. package/dist/esm/templating/dom.js +49 -0
  90. package/dist/esm/templating/html-directive.js +193 -36
  91. package/dist/esm/templating/markup.js +75 -0
  92. package/dist/esm/templating/node-observation.js +51 -45
  93. package/dist/esm/templating/ref.js +8 -25
  94. package/dist/esm/templating/render.js +391 -0
  95. package/dist/esm/templating/repeat.js +83 -79
  96. package/dist/esm/templating/slotted.js +23 -20
  97. package/dist/esm/templating/template.js +51 -93
  98. package/dist/esm/templating/view.js +125 -46
  99. package/dist/esm/templating/when.js +6 -4
  100. package/dist/esm/testing/exports.js +3 -0
  101. package/dist/esm/testing/fakes.js +76 -0
  102. package/dist/esm/testing/fixture.js +86 -0
  103. package/dist/esm/testing/timeout.js +24 -0
  104. package/dist/esm/utilities.js +44 -0
  105. package/dist/fast-element.api.json +12153 -5373
  106. package/dist/fast-element.d.ts +1448 -696
  107. package/dist/fast-element.debug.js +4107 -0
  108. package/dist/fast-element.debug.min.js +1 -0
  109. package/dist/fast-element.js +3817 -4029
  110. package/dist/fast-element.min.js +1 -1
  111. package/dist/fast-element.untrimmed.d.ts +2814 -0
  112. package/docs/api-report.md +567 -254
  113. package/docs/fast-element-2-changes.md +15 -0
  114. package/karma.conf.cjs +6 -17
  115. package/package.json +76 -15
  116. package/dist/dts/dom.d.ts +0 -112
  117. package/dist/dts/observation/array-change-records.d.ts +0 -48
  118. package/dist/dts/observation/array-observer.d.ts +0 -9
  119. package/dist/dts/observation/behavior.d.ts +0 -19
  120. package/dist/esm/dom.js +0 -207
  121. package/dist/esm/observation/array-change-records.js +0 -326
  122. package/dist/esm/observation/array-observer.js +0 -177
@@ -1,46 +1,206 @@
1
- import { DOM } from "../dom.js";
1
+ import { ExecutionContext, } from "../observation/observable.js";
2
+ import { createTypeRegistry } from "../platform.js";
3
+ import { Markup, nextId } from "./markup.js";
4
+ /**
5
+ * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
6
+ * control ViewBehaviors.
7
+ * @public
8
+ */
9
+ export const ViewBehaviorOrchestrator = Object.freeze({
10
+ /**
11
+ * Creates a ViewBehaviorOrchestrator.
12
+ * @param source - The source to to associate behaviors with.
13
+ * @returns A ViewBehaviorOrchestrator.
14
+ */
15
+ create(source) {
16
+ const behaviors = [];
17
+ const targets = {};
18
+ let unbindables = null;
19
+ let isConnected = false;
20
+ return {
21
+ source,
22
+ context: ExecutionContext.default,
23
+ targets,
24
+ get isBound() {
25
+ return isConnected;
26
+ },
27
+ addBehaviorFactory(factory, target) {
28
+ const nodeId = factory.nodeId || (factory.nodeId = nextId());
29
+ factory.id || (factory.id = nextId());
30
+ this.addTarget(nodeId, target);
31
+ this.addBehavior(factory.createBehavior());
32
+ },
33
+ addTarget(nodeId, target) {
34
+ targets[nodeId] = target;
35
+ },
36
+ addBehavior(behavior) {
37
+ behaviors.push(behavior);
38
+ if (isConnected) {
39
+ behavior.bind(this);
40
+ }
41
+ },
42
+ onUnbind(unbindable) {
43
+ if (unbindables === null) {
44
+ unbindables = [];
45
+ }
46
+ unbindables.push(unbindable);
47
+ },
48
+ connectedCallback(controller) {
49
+ if (!isConnected) {
50
+ isConnected = true;
51
+ behaviors.forEach(x => x.bind(this));
52
+ }
53
+ },
54
+ disconnectedCallback(controller) {
55
+ if (isConnected) {
56
+ isConnected = false;
57
+ if (unbindables !== null) {
58
+ unbindables.forEach(x => x.unbind(this));
59
+ }
60
+ }
61
+ },
62
+ };
63
+ },
64
+ });
65
+ const registry = createTypeRegistry();
2
66
  /**
3
67
  * Instructs the template engine to apply behavior to a node.
4
68
  * @public
5
69
  */
6
- export class HTMLDirective {
7
- constructor() {
8
- /**
9
- * The index of the DOM node to which the created behavior will apply.
10
- */
11
- this.targetIndex = 0;
12
- }
70
+ export const HTMLDirective = Object.freeze({
71
+ /**
72
+ * Gets the directive definition associated with the instance.
73
+ * @param instance - The directive instance to retrieve the definition for.
74
+ */
75
+ getForInstance: registry.getForInstance,
76
+ /**
77
+ * Gets the directive definition associated with the specified type.
78
+ * @param type - The directive type to retrieve the definition for.
79
+ */
80
+ getByType: registry.getByType,
81
+ /**
82
+ * Defines an HTMLDirective based on the options.
83
+ * @param type - The type to define as a directive.
84
+ * @param options - Options that specify the directive's application.
85
+ */
86
+ define(type, options) {
87
+ options = options || {};
88
+ options.type = type;
89
+ registry.register(options);
90
+ return type;
91
+ },
92
+ });
93
+ /**
94
+ * Decorator: Defines an HTMLDirective.
95
+ * @param options - Provides options that specify the directive's application.
96
+ * @public
97
+ */
98
+ export function htmlDirective(options) {
99
+ /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
100
+ return function (type) {
101
+ HTMLDirective.define(type, options);
102
+ };
13
103
  }
14
104
  /**
15
- * A {@link HTMLDirective} that targets a named attribute or property on a node.
105
+ * Captures a binding expression along with related information and capabilities.
106
+ *
16
107
  * @public
17
108
  */
18
- export class TargetedHTMLDirective extends HTMLDirective {
19
- constructor() {
20
- super(...arguments);
21
- /**
22
- * Creates a placeholder string based on the directive's index within the template.
23
- * @param index - The index of the directive within the template.
24
- */
25
- this.createPlaceholder = DOM.createInterpolationPlaceholder;
109
+ export class Binding {
110
+ /**
111
+ * Creates a binding.
112
+ * @param evaluate - Evaluates the binding.
113
+ * @param isVolatile - Indicates whether the binding is volatile.
114
+ */
115
+ constructor(evaluate, isVolatile = false) {
116
+ this.evaluate = evaluate;
117
+ this.isVolatile = isVolatile;
26
118
  }
27
119
  }
28
120
  /**
29
- * A directive that attaches special behavior to an element via a custom attribute.
121
+ * The type of HTML aspect to target.
30
122
  * @public
31
123
  */
32
- export class AttachedBehaviorHTMLDirective extends HTMLDirective {
124
+ export const Aspect = Object.freeze({
125
+ /**
126
+ * Not aspected.
127
+ */
128
+ none: 0,
129
+ /**
130
+ * An attribute.
131
+ */
132
+ attribute: 1,
133
+ /**
134
+ * A boolean attribute.
135
+ */
136
+ booleanAttribute: 2,
137
+ /**
138
+ * A property.
139
+ */
140
+ property: 3,
141
+ /**
142
+ * Content
143
+ */
144
+ content: 4,
145
+ /**
146
+ * A token list.
147
+ */
148
+ tokenList: 5,
149
+ /**
150
+ * An event.
151
+ */
152
+ event: 6,
33
153
  /**
34
154
  *
35
- * @param name - The name of the behavior; used as a custom attribute on the element.
36
- * @param behavior - The behavior to instantiate and attach to the element.
37
- * @param options - Options to pass to the behavior during creation.
38
- */
39
- constructor(name, behavior, options) {
40
- super();
41
- this.name = name;
42
- this.behavior = behavior;
155
+ * @param directive - The directive to assign the aspect to.
156
+ * @param value - The value to base the aspect determination on.
157
+ * @remarks
158
+ * If a falsy value is provided, then the content aspect will be assigned.
159
+ */
160
+ assign(directive, value) {
161
+ if (!value) {
162
+ directive.aspectType = Aspect.content;
163
+ return;
164
+ }
165
+ directive.sourceAspect = value;
166
+ switch (value[0]) {
167
+ case ":":
168
+ directive.targetAspect = value.substring(1);
169
+ directive.aspectType =
170
+ directive.targetAspect === "classList"
171
+ ? Aspect.tokenList
172
+ : Aspect.property;
173
+ break;
174
+ case "?":
175
+ directive.targetAspect = value.substring(1);
176
+ directive.aspectType = Aspect.booleanAttribute;
177
+ break;
178
+ case "@":
179
+ directive.targetAspect = value.substring(1);
180
+ directive.aspectType = Aspect.event;
181
+ break;
182
+ default:
183
+ directive.targetAspect = value;
184
+ directive.aspectType = Aspect.attribute;
185
+ break;
186
+ }
187
+ },
188
+ });
189
+ /**
190
+ * A base class used for attribute directives that don't need internal state.
191
+ * @public
192
+ */
193
+ export class StatelessAttachedAttributeDirective {
194
+ /**
195
+ * Creates an instance of RefDirective.
196
+ * @param options - The options to use in configuring the directive.
197
+ */
198
+ constructor(options) {
43
199
  this.options = options;
200
+ /**
201
+ * The unique id of the factory.
202
+ */
203
+ this.id = nextId();
44
204
  }
45
205
  /**
46
206
  * Creates a placeholder string based on the directive's index within the template.
@@ -48,17 +208,14 @@ export class AttachedBehaviorHTMLDirective extends HTMLDirective {
48
208
  * @remarks
49
209
  * Creates a custom attribute placeholder.
50
210
  */
51
- createPlaceholder(index) {
52
- return DOM.createCustomAttributePlaceholder(this.name, index);
211
+ createHTML(add) {
212
+ return Markup.attribute(add(this));
53
213
  }
54
214
  /**
55
- * Creates a behavior for the provided target node.
56
- * @param target - The node instance to create the behavior for.
57
- * @remarks
58
- * Creates an instance of the `behavior` type this directive was constructed with
59
- * and passes the target and options to that `behavior`'s constructor.
215
+ * Creates a behavior.
216
+ * @param targets - The targets available for behaviors to be attached to.
60
217
  */
61
- createBehavior(target) {
62
- return new this.behavior(target, this.options);
218
+ createBehavior() {
219
+ return this;
63
220
  }
64
221
  }
@@ -0,0 +1,75 @@
1
+ const marker = `fast-${Math.random().toString(36).substring(2, 8)}`;
2
+ const interpolationStart = `${marker}{`;
3
+ const interpolationEnd = `}${marker}`;
4
+ const interpolationEndLength = interpolationEnd.length;
5
+ let id = 0;
6
+ /** @internal */
7
+ export const nextId = () => `${marker}-${++id}`;
8
+ /**
9
+ * Common APIs related to markup generation.
10
+ * @public
11
+ */
12
+ export const Markup = Object.freeze({
13
+ /**
14
+ * Creates a placeholder string suitable for marking out a location *within*
15
+ * an attribute value or HTML content.
16
+ * @param index - The directive index to create the placeholder for.
17
+ * @remarks
18
+ * Used internally by binding directives.
19
+ */
20
+ interpolation: (id) => `${interpolationStart}${id}${interpolationEnd}`,
21
+ /**
22
+ * Creates a placeholder that manifests itself as an attribute on an
23
+ * element.
24
+ * @param attributeName - The name of the custom attribute.
25
+ * @param index - The directive index to create the placeholder for.
26
+ * @remarks
27
+ * Used internally by attribute directives such as `ref`, `slotted`, and `children`.
28
+ */
29
+ attribute: (id) => `${nextId()}="${interpolationStart}${id}${interpolationEnd}"`,
30
+ /**
31
+ * Creates a placeholder that manifests itself as a marker within the DOM structure.
32
+ * @param index - The directive index to create the placeholder for.
33
+ * @remarks
34
+ * Used internally by structural directives such as `repeat`.
35
+ */
36
+ comment: (id) => `<!--${interpolationStart}${id}${interpolationEnd}-->`,
37
+ });
38
+ /**
39
+ * Common APIs related to content parsing.
40
+ * @public
41
+ */
42
+ export const Parser = Object.freeze({
43
+ /**
44
+ * Parses text content or HTML attribute content, separating out the static strings
45
+ * from the directives.
46
+ * @param value - The content or attribute string to parse.
47
+ * @param factories - A list of directives to search for in the string.
48
+ * @returns A heterogeneous array of static strings interspersed with
49
+ * directives or null if no directives are found in the string.
50
+ */
51
+ parse(value, factories) {
52
+ const parts = value.split(interpolationStart);
53
+ if (parts.length === 1) {
54
+ return null;
55
+ }
56
+ const result = [];
57
+ for (let i = 0, ii = parts.length; i < ii; ++i) {
58
+ const current = parts[i];
59
+ const index = current.indexOf(interpolationEnd);
60
+ let literal;
61
+ if (index === -1) {
62
+ literal = current;
63
+ }
64
+ else {
65
+ const factoryId = current.substring(0, index);
66
+ result.push(factories[factoryId]);
67
+ literal = current.substring(index + interpolationEndLength);
68
+ }
69
+ if (literal !== "") {
70
+ result.push(literal);
71
+ }
72
+ }
73
+ return result;
74
+ },
75
+ });
@@ -1,72 +1,78 @@
1
- import { Observable } from "../observation/observable.js";
2
1
  import { emptyArray } from "../platform.js";
2
+ import { StatelessAttachedAttributeDirective } from "./html-directive.js";
3
+ const selectElements = (value) => value.nodeType === 1;
3
4
  /**
4
5
  * Creates a function that can be used to filter a Node array, selecting only elements.
5
6
  * @param selector - An optional selector to restrict the filter to.
6
7
  * @public
7
8
  */
8
- export function elements(selector) {
9
- if (selector) {
10
- return function (value, index, array) {
11
- return value.nodeType === 1 && value.matches(selector);
12
- };
13
- }
14
- return function (value, index, array) {
15
- return value.nodeType === 1;
16
- };
17
- }
9
+ export const elements = (selector) => selector
10
+ ? value => value.nodeType === 1 && value.matches(selector)
11
+ : selectElements;
18
12
  /**
19
13
  * A base class for node observation.
20
- * @internal
14
+ * @public
15
+ * @remarks
16
+ * Internally used by the SlottedDirective and the ChildrenDirective.
21
17
  */
22
- export class NodeObservationBehavior {
23
- /**
24
- * Creates an instance of NodeObservationBehavior.
25
- * @param target - The target to assign the nodes property on.
26
- * @param options - The options to use in configuring node observation.
27
- */
28
- constructor(target, options) {
29
- this.target = target;
30
- this.options = options;
31
- this.source = null;
18
+ export class NodeObservationDirective extends StatelessAttachedAttributeDirective {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.sourceProperty = `${this.id}-s`;
32
22
  }
33
23
  /**
34
24
  * Bind this behavior to the source.
35
25
  * @param source - The source to bind to.
36
26
  * @param context - The execution context that the binding is operating within.
27
+ * @param targets - The targets that behaviors in a view can attach to.
37
28
  */
38
- bind(source) {
39
- const name = this.options.property;
40
- this.shouldUpdate = Observable.getAccessors(source).some((x) => x.name === name);
41
- this.source = source;
42
- this.updateTarget(this.computeNodes());
43
- if (this.shouldUpdate) {
44
- this.observe();
45
- }
29
+ bind(controller) {
30
+ const target = controller.targets[this.nodeId];
31
+ target[this.sourceProperty] = controller.source;
32
+ this.updateTarget(controller.source, this.computeNodes(target));
33
+ this.observe(target);
34
+ controller.onUnbind(this);
46
35
  }
47
36
  /**
48
37
  * Unbinds this behavior from the source.
49
38
  * @param source - The source to unbind from.
39
+ * @param context - The execution context that the binding is operating within.
40
+ * @param targets - The targets that behaviors in a view can attach to.
50
41
  */
51
- unbind() {
52
- this.updateTarget(emptyArray);
53
- this.source = null;
54
- if (this.shouldUpdate) {
55
- this.disconnect();
56
- }
42
+ unbind(controller) {
43
+ const target = controller.targets[this.nodeId];
44
+ this.updateTarget(controller.source, emptyArray);
45
+ this.disconnect(target);
46
+ target[this.sourceProperty] = null;
57
47
  }
58
- /** @internal */
59
- handleEvent() {
60
- this.updateTarget(this.computeNodes());
48
+ /**
49
+ * Gets the data source for the target.
50
+ * @param target - The target to get the source for.
51
+ * @returns The source.
52
+ */
53
+ getSource(target) {
54
+ return target[this.sourceProperty];
55
+ }
56
+ /**
57
+ * Updates the source property with the computed nodes.
58
+ * @param source - The source object to assign the nodes property to.
59
+ * @param value - The nodes to assign to the source object property.
60
+ */
61
+ updateTarget(source, value) {
62
+ source[this.options.property] = value;
61
63
  }
62
- computeNodes() {
63
- let nodes = this.getNodes();
64
- if (this.options.filter !== void 0) {
64
+ /**
65
+ * Computes the set of nodes that should be assigned to the source property.
66
+ * @param target - The target to compute the nodes for.
67
+ * @returns The computed nodes.
68
+ * @remarks
69
+ * Applies filters if provided.
70
+ */
71
+ computeNodes(target) {
72
+ let nodes = this.getNodes(target);
73
+ if ("filter" in this.options) {
65
74
  nodes = nodes.filter(this.options.filter);
66
75
  }
67
76
  return nodes;
68
77
  }
69
- updateTarget(value) {
70
- this.source[this.options.property] = value;
71
- }
72
78
  }
@@ -1,38 +1,21 @@
1
- import { AttachedBehaviorHTMLDirective } from "./html-directive.js";
1
+ import { HTMLDirective, StatelessAttachedAttributeDirective, } from "./html-directive.js";
2
2
  /**
3
3
  * The runtime behavior for template references.
4
4
  * @public
5
5
  */
6
- export class RefBehavior {
6
+ export class RefDirective extends StatelessAttachedAttributeDirective {
7
7
  /**
8
- * Creates an instance of RefBehavior.
9
- * @param target - The element to reference.
10
- * @param propertyName - The name of the property to assign the reference to.
8
+ * Bind this behavior.
9
+ * @param controller - The view controller that manages the lifecycle of this behavior.
11
10
  */
12
- constructor(target, propertyName) {
13
- this.target = target;
14
- this.propertyName = propertyName;
11
+ bind(controller) {
12
+ controller.source[this.options] = controller.targets[this.nodeId];
15
13
  }
16
- /**
17
- * Bind this behavior to the source.
18
- * @param source - The source to bind to.
19
- * @param context - The execution context that the binding is operating within.
20
- */
21
- bind(source) {
22
- source[this.propertyName] = this.target;
23
- }
24
- /**
25
- * Unbinds this behavior from the source.
26
- * @param source - The source to unbind from.
27
- */
28
- /* eslint-disable-next-line @typescript-eslint/no-empty-function */
29
- unbind() { }
30
14
  }
15
+ HTMLDirective.define(RefDirective);
31
16
  /**
32
17
  * A directive that observes the updates a property with a reference to the element.
33
18
  * @param propertyName - The name of the property to assign the reference to.
34
19
  * @public
35
20
  */
36
- export function ref(propertyName) {
37
- return new AttachedBehaviorHTMLDirective("fast-ref", RefBehavior, propertyName);
38
- }
21
+ export const ref = (propertyName) => new RefDirective(propertyName);