diff --git a/src/core/vdom.ts b/src/core/vdom.ts index e63124ec3..ebe2936d2 100644 --- a/src/core/vdom.ts +++ b/src/core/vdom.ts @@ -2064,7 +2064,7 @@ export function renderer(renderer: () => RenderResult): Renderer { let rendered: RenderResult; let invalidate: () => void; - next.properties = next.node.properties; + next.properties = { ...next.node.properties }; next.id = next.id || `${wrapperId++}`; _idToWrapperMap.set(next.id, next); const { id, depth, order } = next; @@ -2175,7 +2175,7 @@ export function renderer(renderer: () => RenderResult): Renderer { next.hasAnimations = hasAnimations; next.id = id; next.childDomWrapperId = current.childDomWrapperId; - next.properties = next.node.properties; + next.properties = { ...next.node.properties }; _wrapperSiblingMap.delete(current); if (domNode && domNode.parentNode) { next.domNode = domNode; diff --git a/tests/core/unit/vdom.tsx b/tests/core/unit/vdom.tsx index 10a99f3e0..21c5110ab 100644 --- a/tests/core/unit/vdom.tsx +++ b/tests/core/unit/vdom.tsx @@ -3487,6 +3487,35 @@ jsdomDescribe('vdom', () => { }); }); + it('should clone properties', () => { + const factory = create().properties<{ count: number }>(); + const Foo = factory(function Foo({ properties }) { + return
{`${properties().count}`}
; + }); + const properties: any = { count: 0 }; + const App = create({ invalidator })(function App({ middleware: { invalidator } }) { + return ( +
+
+ ); + }); + const root = document.createElement('div'); + const r = renderer(() => App({})); + r.mount({ domNode: root }); + console.log(root.innerHTML); + assert.strictEqual(root.innerHTML, '
0
'); + properties.count = 1; + (root.children[0].children[0] as any).click(); + resolvers.resolveRAF(); + assert.strictEqual(root.innerHTML, '
1
'); + }); + it('registry items', () => { const createWidget = create(); let resolver = () => {};