dom-expressions 0.32.9 → 0.32.12

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.32.9",
4
+ "version": "0.32.12",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "devalue": "^2.0.1"
21
21
  },
22
22
  "devDependencies": {
23
- "babel-plugin-jsx-dom-expressions": "^0.32.9"
23
+ "babel-plugin-jsx-dom-expressions": "^0.32.11"
24
24
  },
25
- "gitHead": "8a9b236619e0d18abee5da391cae33e25e82f92a"
25
+ "gitHead": "4faa817f76c32e3eb1a59887183599155145def5"
26
26
  }
package/src/client.js CHANGED
@@ -107,8 +107,10 @@ export function classList(node, value, prev = {}) {
107
107
 
108
108
  export function style(node, value, prev = {}) {
109
109
  const nodeStyle = node.style;
110
- if (value == null || typeof value === "string") return (nodeStyle.cssText = value);
111
- typeof prev === "string" && (prev = {});
110
+ const prevString = typeof prev === "string";
111
+ if ((value == null && prevString) || typeof value === "string") return (nodeStyle.cssText = value);
112
+ prevString && (nodeStyle.cssText = undefined, prev = {});
113
+ value || (value = {});
112
114
  let v, s;
113
115
  for (s in prev) {
114
116
  value[s] == null && nodeStyle.removeProperty(s);
@@ -162,11 +164,11 @@ export function insert(parent, accessor, marker, initial) {
162
164
  effect(current => insertExpression(parent, accessor(), current, marker), initial);
163
165
  }
164
166
 
165
- export function assign(node, props, isSVG, skipChildren, prevProps = {}) {
167
+ export function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
166
168
  for (const prop in prevProps) {
167
169
  if (!(prop in props)) {
168
170
  if (prop === "children") continue;
169
- assignProp(node, prop, null, prevProps[prop], isSVG);
171
+ assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
170
172
  }
171
173
  }
172
174
  for (const prop in props) {
@@ -175,7 +177,7 @@ export function assign(node, props, isSVG, skipChildren, prevProps = {}) {
175
177
  continue;
176
178
  }
177
179
  const value = props[prop];
178
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
180
+ prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
179
181
  }
180
182
  }
181
183
 
@@ -259,13 +261,15 @@ function toggleClassKey(node, key, value) {
259
261
  node.classList.toggle(classNames[i], value);
260
262
  }
261
263
 
262
- function assignProp(node, prop, value, prev, isSVG) {
264
+ function assignProp(node, prop, value, prev, isSVG, skipRef) {
263
265
  let isCE, isProp, isChildProp;
264
266
  if (prop === "style") return style(node, value, prev);
265
267
  if (prop === "classList") return classList(node, value, prev);
266
268
  if (value === prev) return prev;
267
269
  if (prop === "ref") {
268
- value(node);
270
+ if (!skipRef) {
271
+ value(node);
272
+ }
269
273
  } else if (prop.slice(0, 3) === "on:") {
270
274
  node.addEventListener(prop.slice(3), value);
271
275
  } else if (prop.slice(0, 10) === "oncapture:") {
@@ -325,7 +329,8 @@ function spreadExpression(node, props, prevProps = {}, isSVG, skipChildren) {
325
329
  if (!skipChildren && "children" in props) {
326
330
  effect(() => (prevProps.children = insertExpression(node, props.children, prevProps.children)));
327
331
  }
328
- effect(() => assign(node, props, isSVG, true, prevProps));
332
+ props.ref && props.ref(node);
333
+ effect(() => assign(node, props, isSVG, true, prevProps, true));
329
334
  return prevProps;
330
335
  }
331
336
 
@@ -453,7 +458,8 @@ function gatherHydratable(element, root) {
453
458
  for (let i = 0; i < templates.length; i++) {
454
459
  const node = templates[i];
455
460
  const key = node.getAttribute("data-hk");
456
- if (!root || key.startsWith(root)) sharedConfig.registry.set(key, node);
461
+ if ((!root || key.startsWith(root)) && !sharedConfig.registry.has(key))
462
+ sharedConfig.registry.set(key, node);
457
463
  }
458
464
  }
459
465
 
package/src/jsx.d.ts CHANGED
@@ -21,7 +21,7 @@ export namespace JSX {
21
21
  (): Element;
22
22
  }
23
23
  interface ElementClass {
24
- render(props: any): Element;
24
+ // empty, libs can define requirements downstream
25
25
  }
26
26
  type LibraryManagedAttributes<Component, Props> = Props;
27
27
  interface ElementChildrenAttribute {
@@ -3112,7 +3112,7 @@ export namespace JSX {
3112
3112
  ZoomAndPanSVGAttributes,
3113
3113
  PresentationSVGAttributes {
3114
3114
  version?: string;
3115
- "base-profile"?: string;
3115
+ baseProfile?: string;
3116
3116
  x?: number | string;
3117
3117
  y?: number | string;
3118
3118
  width?: number | string;
package/src/server.js CHANGED
@@ -428,7 +428,19 @@ function injectScripts(html, scripts, nonce) {
428
428
  }
429
429
 
430
430
  function serializeError(error) {
431
- return error.message ? `new Error(${devalue(error.message)})` : devalue(error);
431
+ if (error.message) {
432
+ const fields = {};
433
+ const keys = Object.getOwnPropertyNames(error);
434
+ for (let i = 0; i < keys.length; i++) {
435
+ const key = keys[i];
436
+ const value = error[key];
437
+ if (!value || (key !== "message" && typeof value !== "function")) {
438
+ fields[key] = value;
439
+ }
440
+ }
441
+ return `Object.assign(new Error(${devalue(error.message)}), ${devalue(fields)})`;
442
+ }
443
+ return devalue(error);
432
444
  }
433
445
 
434
446
  function waitForFragments(registry, key) {
package/src/universal.js CHANGED
@@ -218,16 +218,14 @@ export function createRenderer({
218
218
  () => (prevProps.children = insertExpression(node, props.children, prevProps.children))
219
219
  );
220
220
  }
221
+ props.ref && props.ref(node);
221
222
  effect(() => {
222
223
  for (const prop in props) {
223
- if (prop === "children") continue;
224
+ if (prop === "children" || prop === "ref") continue;
224
225
  const value = props[prop];
225
226
  if (value === prevProps[prop]) continue;
226
- if (prop === "ref") value(node);
227
- else {
228
- setProperty(node, prop, value, prevProps[prop]);
229
- prevProps[prop] = value;
230
- }
227
+ setProperty(node, prop, value, prevProps[prop]);
228
+ prevProps[prop] = value;
231
229
  }
232
230
  });
233
231
  return prevProps;