@microsoft/fast-html 1.0.0-alpha.33 → 1.0.0-alpha.34

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.
@@ -20,6 +20,7 @@ export declare class ObserverMap {
20
20
  * Creates a property change handler function for observable properties
21
21
  * This handler is called when an observable property transitions from undefined to a defined value
22
22
  * @param propertyName - The name of the property for which to create the change handler
23
+ * @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
23
24
  * @returns A function that handles property changes and sets up proxies for object values
24
25
  */
25
26
  private defineChanged;
@@ -10,20 +10,24 @@ export class ObserverMap {
10
10
  * Creates a property change handler function for observable properties
11
11
  * This handler is called when an observable property transitions from undefined to a defined value
12
12
  * @param propertyName - The name of the property for which to create the change handler
13
+ * @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
13
14
  * @returns A function that handles property changes and sets up proxies for object values
14
15
  */
15
- this.defineChanged = (propertyName) => {
16
+ this.defineChanged = (propertyName, existingChangedMethod) => {
16
17
  const getAndAssignObservablesAlias = this.getAndAssignObservables;
17
18
  const schema = this.schema;
18
19
  function instanceResolverChanged(prev, next) {
19
- if (prev === undefined ||
20
+ if (next === null || typeof next !== "object") {
21
+ this[propertyName] = next;
22
+ }
23
+ else if (prev === undefined ||
20
24
  ((prev === null || prev === void 0 ? void 0 : prev.$isProxy) && !(next === null || next === void 0 ? void 0 : next.$isProxy)) ||
21
25
  (Array.isArray(prev) &&
22
26
  Array.isArray(next) &&
23
27
  !(next === null || next === void 0 ? void 0 : next.$fastController))) {
24
- const proxy = getAndAssignObservablesAlias(this, propertyName, next, schema);
25
- this[propertyName] = proxy;
28
+ this[propertyName] = getAndAssignObservablesAlias(this, propertyName, next, schema);
26
29
  }
30
+ existingChangedMethod === null || existingChangedMethod === void 0 ? void 0 : existingChangedMethod.call(this, prev, next);
27
31
  }
28
32
  return instanceResolverChanged;
29
33
  };
@@ -32,10 +36,15 @@ export class ObserverMap {
32
36
  }
33
37
  defineProperties() {
34
38
  const propertyNames = this.schema.getRootProperties();
39
+ const existingAccessors = Observable.getAccessors(this.classPrototype);
35
40
  for (const propertyName of propertyNames) {
36
- Observable.defineProperty(this.classPrototype, propertyName);
37
- this.classPrototype[`${propertyName}Changed`] =
38
- this.defineChanged(propertyName);
41
+ // Skip if property already has an accessor (from `@attr` or `@observable` decorator)
42
+ if (!existingAccessors.some(accessor => accessor.name === propertyName)) {
43
+ Observable.defineProperty(this.classPrototype, propertyName);
44
+ }
45
+ const changedMethodName = `${propertyName}Changed`;
46
+ const existingChangedMethod = this.classPrototype[changedMethodName];
47
+ this.classPrototype[changedMethodName] = this.defineChanged(propertyName, existingChangedMethod);
39
48
  }
40
49
  }
41
50
  /**
@@ -105,6 +105,7 @@ export declare class ObserverMap {
105
105
  * Creates a property change handler function for observable properties
106
106
  * This handler is called when an observable property transitions from undefined to a defined value
107
107
  * @param propertyName - The name of the property for which to create the change handler
108
+ * @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
108
109
  * @returns A function that handles property changes and sets up proxies for object values
109
110
  */
110
111
  private defineChanged;
@@ -105,6 +105,7 @@ export declare class ObserverMap {
105
105
  * Creates a property change handler function for observable properties
106
106
  * This handler is called when an observable property transitions from undefined to a defined value
107
107
  * @param propertyName - The name of the property for which to create the change handler
108
+ * @param existingChangedMethod - Optional existing changed method to call after the instance resolver logic
108
109
  * @returns A function that handles property changes and sets up proxies for object values
109
110
  */
110
111
  private defineChanged;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-html",
3
- "version": "1.0.0-alpha.33",
3
+ "version": "1.0.0-alpha.34",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -11,7 +11,7 @@
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/Microsoft/fast.git",
14
- "directory": "packages/web-components/fast-html"
14
+ "directory": "packages/fast-html"
15
15
  },
16
16
  "bugs": {
17
17
  "url": "https://github.com/Microsoft/fast/issues/new/choose"