@matthesketh/utopia-runtime 0.0.3 → 0.0.5

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/dist/index.cjs CHANGED
@@ -300,13 +300,14 @@ function clearNodes(nodes) {
300
300
  function createIf(anchor, condition, renderTrue, renderFalse) {
301
301
  let currentNodes = [];
302
302
  let lastConditionTruthy;
303
- const parent = anchor.parentNode;
304
303
  const dispose = (0, import_utopia_core.effect)(() => {
305
304
  const truthy = !!condition();
306
305
  if (truthy === lastConditionTruthy) {
307
306
  return;
308
307
  }
309
308
  lastConditionTruthy = truthy;
309
+ const parent = anchor.parentNode;
310
+ if (!parent) return;
310
311
  clearNodes(currentNodes);
311
312
  if (truthy) {
312
313
  const node = renderTrue();
@@ -325,10 +326,11 @@ function createIf(anchor, condition, renderTrue, renderFalse) {
325
326
  }
326
327
  function createFor(anchor, list, renderItem, key) {
327
328
  let currentNodes = [];
328
- const parent = anchor.parentNode;
329
329
  void key;
330
330
  const dispose = (0, import_utopia_core.effect)(() => {
331
331
  const items = list();
332
+ const parent = anchor.parentNode;
333
+ if (!parent) return;
332
334
  clearNodes(currentNodes);
333
335
  for (let i = 0; i < items.length; i++) {
334
336
  const node = renderItem(items[i], i);
package/dist/index.js CHANGED
@@ -252,13 +252,14 @@ function clearNodes(nodes) {
252
252
  function createIf(anchor, condition, renderTrue, renderFalse) {
253
253
  let currentNodes = [];
254
254
  let lastConditionTruthy;
255
- const parent = anchor.parentNode;
256
255
  const dispose = effect(() => {
257
256
  const truthy = !!condition();
258
257
  if (truthy === lastConditionTruthy) {
259
258
  return;
260
259
  }
261
260
  lastConditionTruthy = truthy;
261
+ const parent = anchor.parentNode;
262
+ if (!parent) return;
262
263
  clearNodes(currentNodes);
263
264
  if (truthy) {
264
265
  const node = renderTrue();
@@ -277,10 +278,11 @@ function createIf(anchor, condition, renderTrue, renderFalse) {
277
278
  }
278
279
  function createFor(anchor, list, renderItem, key) {
279
280
  let currentNodes = [];
280
- const parent = anchor.parentNode;
281
281
  void key;
282
282
  const dispose = effect(() => {
283
283
  const items = list();
284
+ const parent = anchor.parentNode;
285
+ if (!parent) return;
284
286
  clearNodes(currentNodes);
285
287
  for (let i = 0; i < items.length; i++) {
286
288
  const node = renderItem(items[i], i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matthesketh/utopia-runtime",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "DOM renderer and component lifecycle for UtopiaJS",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "dist"
41
41
  ],
42
42
  "dependencies": {
43
- "@matthesketh/utopia-core": "0.0.3"
43
+ "@matthesketh/utopia-core": "0.0.5"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsup src/index.ts --format esm,cjs --dts",