clava 0.6.2 → 0.6.3

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.
@@ -1,4 +1,4 @@
1
- import { hasOwn } from "./utils.ts";
1
+ import { getOwn, hasOwn } from "./utils.ts";
2
2
 
3
3
  export interface CreationFrame {
4
4
  stack?: string;
@@ -105,8 +105,9 @@ export function accumulateUnstableVariantChanges(
105
105
  ): void {
106
106
  for (const key in next) {
107
107
  if (!hasOwn(next, key)) continue;
108
- if (!Object.is(prev[key], next[key])) {
109
- setVariantChange(into, key, prev[key], next[key]);
108
+ const from = getOwn(prev, key);
109
+ if (!Object.is(from, next[key])) {
110
+ setVariantChange(into, key, from, next[key]);
110
111
  }
111
112
  }
112
113
  for (const key in prev) {
package/src/utils.ts CHANGED
@@ -2,6 +2,20 @@ import type { HTMLCSSProperties, StyleValue } from "./types.ts";
2
2
 
3
3
  export const hasOwn = Object.hasOwn;
4
4
 
5
+ /**
6
+ * Reads a key that may be absent from a plain record. Variant, prop, and config
7
+ * records are plain objects, so a key inherited from a polluted
8
+ * `Object.prototype` would otherwise read back like a value the caller passed
9
+ * or Clava itself resolved.
10
+ */
11
+ export function getOwn<T extends object, K extends keyof T & string>(
12
+ record: T,
13
+ key: K,
14
+ ): T[K] | undefined {
15
+ if (!hasOwn(record, key)) return undefined;
16
+ return record[key];
17
+ }
18
+
5
19
  // Keep this explicit so normalization does not depend on browser globals.
6
20
  // Vendor-prefixed variants are derived below instead of duplicating the list.
7
21
  const unitlessNumberProperties = new Set([