dom-expressions 0.40.7 → 0.40.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dom-expressions",
3
3
  "description": "A Fine-Grained Runtime for Performant DOM Rendering",
4
- "version": "0.40.7",
4
+ "version": "0.40.10",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -24,10 +24,10 @@
24
24
  "seroval-plugins": "~1.5.0"
25
25
  },
26
26
  "devDependencies": {
27
- "babel-plugin-jsx-dom-expressions": "^0.40.7",
27
+ "babel-plugin-jsx-dom-expressions": "^0.40.10",
28
28
  "csstype": "^3.1",
29
29
  "seroval": "~1.5.0",
30
30
  "seroval-plugins": "~1.5.0"
31
31
  },
32
- "gitHead": "3c01eb2ac61b193d4164319befe3f1b2634549cb"
32
+ "gitHead": "727298ff79a54ef5299d3649ab7f4105a326e9b3"
33
33
  }
package/src/client.d.ts CHANGED
@@ -56,9 +56,9 @@ export function addEventListener(
56
56
  ): void;
57
57
  export function classList(
58
58
  node: Element,
59
- value: { [k: string]: boolean },
60
- prev?: { [k: string]: boolean }
61
- ): { [k: string]: boolean };
59
+ value: JSX.ClassList,
60
+ prev?: JSX.ClassList
61
+ ): JSX.ClassList;
62
62
  export function style(
63
63
  node: Element,
64
64
  value: { [k: string]: string },
package/src/client.js CHANGED
@@ -107,7 +107,14 @@ export function clearDelegatedEvents(document = window.document) {
107
107
 
108
108
  export function setProperty(node, name, value) {
109
109
  if (isHydrating(node)) return;
110
- node[name] = value;
110
+ // Compiler on next emits `el.value = v ?? ""` for input/textarea. 0.40.x
111
+ // still goes through setProperty, so apply the same rule here (#2957).
112
+ if (
113
+ (name === "value" || name === "defaultValue") &&
114
+ (node.nodeName === "INPUT" || node.nodeName === "TEXTAREA")
115
+ )
116
+ node[name] = value ?? "";
117
+ else node[name] = value;
111
118
  }
112
119
 
113
120
  export function setAttribute(node, name, value) {
@@ -384,6 +391,12 @@ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
384
391
  } else if (isHydrating(node)) return value;
385
392
  if (prop === "class" || prop === "className") className(node, value);
386
393
  else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;
394
+ else if (
395
+ (prop === "value" || prop === "defaultValue") &&
396
+ (node.nodeName === "INPUT" || node.nodeName === "TEXTAREA")
397
+ )
398
+ // Spread path assigned raw, so value={undefined} painted "undefined" (#2957).
399
+ node[propAlias || prop] = value ?? "";
387
400
  else node[propAlias || prop] = value;
388
401
  } else {
389
402
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
package/src/jsx-h.d.ts CHANGED
@@ -140,14 +140,13 @@ export namespace JSX {
140
140
  interface IntrinsicAttributes {
141
141
  ref?: unknown | ((e: unknown) => void) | undefined;
142
142
  }
143
+ export type ClassList = {
144
+ [k: string]: boolean | undefined;
145
+ };
143
146
  interface CustomAttributes<T> {
144
147
  ref?: T | ((el: T) => void) | undefined;
145
148
  children?: FunctionMaybe<Element | undefined>;
146
- classList?:
147
- | {
148
- [k: string]: boolean | undefined;
149
- }
150
- | undefined;
149
+ classList?: ClassList | undefined;
151
150
  $ServerOnly?: boolean | undefined;
152
151
  }
153
152
  type Accessor<T> = () => T;
package/src/jsx.d.ts CHANGED
@@ -137,14 +137,13 @@ export namespace JSX {
137
137
  interface IntrinsicAttributes {
138
138
  ref?: unknown | ((e: unknown) => void) | undefined;
139
139
  }
140
+ export type ClassList = {
141
+ [k: string]: boolean | undefined;
142
+ };
140
143
  interface CustomAttributes<T> {
141
144
  ref?: T | ((el: T) => void) | undefined;
142
145
  children?: Element | undefined;
143
- classList?:
144
- | {
145
- [k: string]: boolean | undefined;
146
- }
147
- | undefined;
146
+ classList?: ClassList | undefined;
148
147
  $ServerOnly?: boolean | undefined;
149
148
  }
150
149
  type Accessor<T> = () => T;
package/src/server.d.ts CHANGED
@@ -50,7 +50,7 @@ export function ssrElement(
50
50
  children: any,
51
51
  needsId: boolean
52
52
  ): { t: string };
53
- export function ssrClassList(value: { [k: string]: boolean }): string;
53
+ export function ssrClassList(value: JSX.ClassList): string;
54
54
  export function ssrStyle(value: { [k: string]: string }): string;
55
55
  export function ssrAttribute(key: string, value: any, isBoolean: boolean): string;
56
56
  export function ssrHydrationKey(): string;
@@ -107,9 +107,9 @@ export function untrack<T>(fn: () => T): T;
107
107
  /** @deprecated not supported on the server side */
108
108
  export function classList(
109
109
  node: Element,
110
- value: { [k: string]: boolean },
111
- prev?: { [k: string]: boolean }
112
- ): { [k: string]: boolean };
110
+ value: JSX.ClassList,
111
+ prev?: JSX.ClassList
112
+ ): JSX.ClassList;
113
113
 
114
114
  /** @deprecated not supported on the server side */
115
115
  export function style(
package/src/server.js CHANGED
@@ -432,7 +432,16 @@ export function escape(s, attr) {
432
432
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
433
433
  return s;
434
434
  }
435
- if (attr && t === "boolean") return String(s);
435
+ if (attr) {
436
+ if (t === "boolean") return String(s);
437
+ // Nullish values pass through so callers can omit the attribute, and
438
+ // numbers can never contain `&` or `"`. Everything else (arrays,
439
+ // objects) would be stringified by the surrounding template literal
440
+ // anyway, so coerce to the final string here first — matching what the
441
+ // client DOM receives — and run it through the normal string path.
442
+ if (s == null || t === "number") return s;
443
+ return escape(String(s), attr);
444
+ }
436
445
  return s;
437
446
  }
438
447
  const delim = attr ? '"' : "<";