@pyreon/runtime-dom 0.5.5 → 0.5.6

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.
@@ -13,6 +13,7 @@ import {
13
13
  onMount,
14
14
  onUnmount,
15
15
  onUpdate,
16
+ Portal,
16
17
  } from "@pyreon/core"
17
18
  import { signal } from "@pyreon/reactivity"
18
19
  import { installDevTools, registerComponent, unregisterComponent } from "../devtools"
@@ -360,6 +361,37 @@ describe("mount.ts — uncovered branches", () => {
360
361
  warnSpy.mockRestore()
361
362
  })
362
363
 
364
+ test("component returning Promise triggers dev warning", () => {
365
+ const el = container()
366
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {})
367
+
368
+ const AsyncComp = (() => Promise.resolve(null)) as unknown as ComponentFn
369
+ mount(h(AsyncComp, null), el)
370
+
371
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("returned a Promise"))
372
+ warnSpy.mockRestore()
373
+ })
374
+
375
+ test("void element with children triggers dev warning", () => {
376
+ const el = container()
377
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {})
378
+
379
+ mount(h("img", null, "child text"), el)
380
+
381
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("void element"))
382
+ warnSpy.mockRestore()
383
+ })
384
+
385
+ test("Portal with falsy target warns", () => {
386
+ const el = container()
387
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {})
388
+
389
+ mount(h(Portal, { target: null }), el)
390
+
391
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("Portal"))
392
+ warnSpy.mockRestore()
393
+ })
394
+
363
395
  test("component subtree mount error with propagateError (lines 298-309)", () => {
364
396
  const el = container()
365
397
  const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {})
@@ -914,6 +946,16 @@ describe("props.ts — uncovered branches", () => {
914
946
  unmount()
915
947
  })
916
948
 
949
+ test("non-function event handler triggers dev warning", () => {
950
+ const el = container()
951
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {})
952
+
953
+ mount(h("button", { onClick: "not a function" }), el)
954
+
955
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("non-function value"))
956
+ warnSpy.mockRestore()
957
+ })
958
+
917
959
  test("n-show prop toggles display (lines 273-277)", () => {
918
960
  const el = container()
919
961
  const visible = signal(true)
@@ -975,6 +975,23 @@ describe("mount — props (extended)", () => {
975
975
  expect(div.style.marginTop).toBe("10px")
976
976
  })
977
977
 
978
+ test("style object auto-appends px to numeric values", () => {
979
+ const el = container()
980
+ mount(h("div", { style: { height: 100, marginTop: 20, opacity: 0.5, zIndex: 10 } }), el)
981
+ const div = el.querySelector("div") as HTMLElement
982
+ expect(div.style.height).toBe("100px")
983
+ expect(div.style.marginTop).toBe("20px")
984
+ expect(div.style.opacity).toBe("0.5")
985
+ expect(div.style.zIndex).toBe("10")
986
+ })
987
+
988
+ test("style object handles CSS custom properties", () => {
989
+ const el = container()
990
+ mount(h("div", { style: { "--my-color": "red" } }), el)
991
+ const div = el.querySelector("div") as HTMLElement
992
+ expect(div.style.getPropertyValue("--my-color")).toBe("red")
993
+ })
994
+
978
995
  test("className sets class attribute", () => {
979
996
  const el = container()
980
997
  mount(h("div", { className: "my-class" }), el)
@@ -1841,7 +1858,6 @@ describe("hydrateRoot — extended", () => {
1841
1858
  const Comp = defineComponent(() => {
1842
1859
  onMount(() => {
1843
1860
  mountCalled = true
1844
- return undefined
1845
1861
  })
1846
1862
  return h("span", null, "mounted")
1847
1863
  })
@@ -251,7 +251,6 @@ export function TransitionGroup<T = unknown>(props: TransitionGroupProps<T>): VN
251
251
  // Fire the effect once the container is in the DOM
252
252
  onMount(() => {
253
253
  ready.set(true)
254
- return undefined
255
254
  })
256
255
 
257
256
  onUnmount(() => {