From 1d12dedcb064f31dd07a2f0e21d31bbd9bff3be6 Mon Sep 17 00:00:00 2001 From: JerryWu <409187100@qq.com> Date: Sat, 25 Jan 2025 09:43:27 +0800 Subject: [PATCH] fix: solve all problems that mentioned --- .../qwik/src/core/shared/component-execution.ts | 14 +++++++------- packages/qwik/src/core/ssr/ssr-render-jsx.ts | 2 +- packages/qwik/src/core/tests/use-on.spec.tsx | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/qwik/src/core/shared/component-execution.ts b/packages/qwik/src/core/shared/component-execution.ts index a81d6ddd960..239f4135703 100644 --- a/packages/qwik/src/core/shared/component-execution.ts +++ b/packages/qwik/src/core/shared/component-execution.ts @@ -138,7 +138,7 @@ function addUseOnEvents( useOnEvents: UseOnMap ): ValueOrPromise | null | JSXOutput> { const jsxElement = findFirstStringJSX(jsx); - let _jsx = jsx; + let jsxResult = jsx; return maybeThen(jsxElement, (jsxElement) => { let isInvisibleComponent = false; if (!jsxElement) { @@ -157,14 +157,14 @@ function addUseOnEvents( if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) { if (isInvisibleComponent) { if (key === 'onQvisible$') { - const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(_jsx); - _jsx = jsx; + const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult); + jsxResult = jsx; if (jsxElement) { addUseOnEvent(jsxElement, 'document:onQinit$', useOnEvents[key]); } } else if (key.startsWith('document:') || key.startsWith('window:')) { - const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(_jsx); - _jsx = jsx; + const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult); + jsxResult = jsx; if (jsxElement) { addUseOnEvent(jsxElement, key, useOnEvents[key]); } @@ -182,7 +182,7 @@ function addUseOnEvents( } } } - return _jsx || jsx; + return jsxResult; }); } @@ -255,7 +255,7 @@ function addScriptNodeForInvisibleComponents( return [jsxElement, jsx]; } else if (Array.isArray(jsx) && jsx.length) { // get first element - const [jsxElement, _jsx] = addScriptNodeForInvisibleComponents(jsx[0]); + const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]); return [jsxElement, jsx]; } diff --git a/packages/qwik/src/core/ssr/ssr-render-jsx.ts b/packages/qwik/src/core/ssr/ssr-render-jsx.ts index 9f0b027acb2..93c89d87848 100644 --- a/packages/qwik/src/core/ssr/ssr-render-jsx.ts +++ b/packages/qwik/src/core/ssr/ssr-render-jsx.ts @@ -302,7 +302,7 @@ function processJSXNode( options.parentComponentFrame ); - const jsxOutput: any = applyQwikComponentBody(ssr, jsx, type); + const jsxOutput = applyQwikComponentBody(ssr, jsx, type); const compStyleComponentId = addComponentStylePrefix(host.getProp(QScopedStyle)); enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)); enqueue(ssr.closeComponent); diff --git a/packages/qwik/src/core/tests/use-on.spec.tsx b/packages/qwik/src/core/tests/use-on.spec.tsx index 54718308d80..8d301e0fd63 100644 --- a/packages/qwik/src/core/tests/use-on.spec.tsx +++ b/packages/qwik/src/core/tests/use-on.spec.tsx @@ -23,7 +23,7 @@ Error.stackTraceLimit = 100; describe.each([ { render: ssrRenderToDom }, // - { render: domRender }, /// + { render: domRender }, // ])('$render.name: useOn', ({ render }) => { it('should update value', async () => { const Counter = component$((props: { initial: number }) => {