From 9c2523e3ce82f84c9d64166ff61c5ed75536a8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 19 Nov 2021 08:31:19 +0100 Subject: [PATCH] wip --- src/component/component_node.ts | 4 ++-- .../__snapshots__/rendering.test.ts.snap | 24 +++++++++++++++++++ tests/components/rendering.test.ts | 24 +++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/component/component_node.ts b/src/component/component_node.ts index c17d1966..4e096a79 100644 --- a/src/component/component_node.ts +++ b/src/component/component_node.ts @@ -1,6 +1,7 @@ import type { App, Env } from "../app/app"; import { BDom, VNode } from "../blockdom"; import { Component, Props } from "./component"; +import { fibersInError, handleError } from "./error_handling"; import { Fiber, makeChildFiber, @@ -8,9 +9,8 @@ import { MountFiber, MountOptions, RootFiber, - __internal__destroyed, + __internal__destroyed } from "./fibers"; -import { handleError, fibersInError } from "./error_handling"; import { applyDefaultProps } from "./props_validation"; import { STATUS } from "./status"; import { applyStyles } from "./style"; diff --git a/tests/components/__snapshots__/rendering.test.ts.snap b/tests/components/__snapshots__/rendering.test.ts.snap index 185a10de..401d0864 100644 --- a/tests/components/__snapshots__/rendering.test.ts.snap +++ b/tests/components/__snapshots__/rendering.test.ts.snap @@ -1,5 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`rendering semantics blabla 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + return function template(ctx, node, key = \\"\\") { + return text(ctx['props'].a.b); + } +}" +`; + +exports[`rendering semantics blabla 2`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + return function template(ctx, node, key = \\"\\") { + return component(\`Child\`, {a: ctx['state']}, key + \`__1\`, node, ctx); + } +}" +`; + exports[`rendering semantics can force a render to update sub tree 1`] = ` "function anonymous(bdom, helpers ) { diff --git a/tests/components/rendering.test.ts b/tests/components/rendering.test.ts index adefc8dc..1e9d9f1d 100644 --- a/tests/components/rendering.test.ts +++ b/tests/components/rendering.test.ts @@ -83,4 +83,28 @@ describe("rendering semantics", () => { expect(parentN).toBe(2); expect(childN).toBe(2); }); + + test("blabla", async () => { + class Child extends Component { + static template = xml``; + + } + + class Parent extends Component { + static template = xml` + + `; + static components = { Child }; + + state = useState({ b: 1 }); + } + + const parent = await mount(Parent, fixture); + + expect(fixture.innerHTML).toBe("1"); + + parent.state.b = 3; + await nextTick(); + expect(fixture.innerHTML).toBe("3"); + }); });