Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the use hook didn't work when type is Slot. #7250

Open
wants to merge 21 commits into
base: build/v2
Choose a base branch
from

Conversation

JerryWu1234
Copy link
Contributor

@JerryWu1234 JerryWu1234 commented Jan 13, 2025

What is it?

#7230

fix: modify jsx output when it is Slot.
example :

</Slot>
<>
  <script>
  </Slot>
<>

Description

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I made corresponding changes to the Qwik docs
  • I added new tests to cover the fix / functionality

Copy link

changeset-bot bot commented Jan 13, 2025

🦋 Changeset detected

Latest commit: defcde7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/core Patch
eslint-plugin-qwik Patch
@qwik.dev/react Patch
@qwik.dev/router Patch
create-qwik Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JerryWu1234 JerryWu1234 changed the base branch from main to build/v2 January 13, 2025 13:39
@JerryWu1234 JerryWu1234 changed the title V2v2v2 fix: a draft for discovering a V2 bug Jan 15, 2025
Copy link

pkg-pr-new bot commented Jan 15, 2025

Open in Stackblitz

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@7250
npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@7250
npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@7250
npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@7250

commit: 1d7a60d

Copy link
Contributor

github-actions bot commented Jan 15, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 1d7a60d

Copy link
Member

@Varixo Varixo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you for your contribution, but this is not a good solution. We can't add special condition for every edge case in the vnode-diff.

Tip: the problem is somewhere in this function

@JerryWu1234
Copy link
Contributor Author

JerryWu1234 commented Jan 16, 2025

Hey, thank you for your contribution, but this is not a good solution. We can't add special conditionl for every edge case in the vnode-diff.

Tip: the problem is somewhere in this function

There are a couple of problems. Q: template also has a problem with usedocument. However I will find a better way to do it. And will tell you when I finish it

@Varixo
Copy link
Member

Varixo commented Jan 16, 2025

Hey, thank you for your contribution, but this is not a good solution. We can't add special conditionl for every edge case in the vnode-diff.
Tip: the problem is somewhere in this function

There are a couple of problems. Q: template also has a problem with usedocument. However I will find a better way to do it. And will tell you when I finish it

I think we need to just modify jsx output to be:

<>
  <script ... />
  <Slot />
</>

instead of just <Slot />

@Varixo
Copy link
Member

Varixo commented Jan 16, 2025

if you need more help with that let me know

@JerryWu1234 JerryWu1234 changed the title fix: a draft for discovering a V2 bug fix: the use hook didn't work when type is Slot. Jan 20, 2025
@JerryWu1234 JerryWu1234 marked this pull request as ready for review January 20, 2025 05:28
@JerryWu1234 JerryWu1234 requested a review from a team as a code owner January 20, 2025 05:28
@JerryWu1234 JerryWu1234 requested a review from Varixo January 20, 2025 05:29
Copy link
Member

@Varixo Varixo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! I have added some comments

packages/qwik/src/core/tests/use-on.spec.tsx Outdated Show resolved Hide resolved
packages/qwik/src/core/tests/use-on.spec.tsx Outdated Show resolved Hide resolved
packages/qwik/src/core/shared/component-execution.ts Outdated Show resolved Hide resolved
Copy link
Member

@Varixo Varixo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Nice job! 😃
I added some comments

@@ -176,7 +182,7 @@ function addUseOnEvents(
}
}
}
return jsxElement;
return _jsx || jsx;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just _jsx isn't enough?

const jsxElement = findFirstStringJSX(jsx);
let _jsx = jsx;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't use _ convention. Maybe we can name it jsxResult?

Comment on lines +258 to +259
const [jsxElement, _jsx] = addScriptNodeForInvisibleComponents(jsx[0]);
return [jsxElement, jsx];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return addScriptNodeForInvisibleComponents(jsx[0]) doesn't work?

@@ -300,7 +301,8 @@ function processJSXNode(
options.styleScoped,
options.parentComponentFrame
);
const jsxOutput = applyQwikComponentBody(ssr, jsx, type);

const jsxOutput: any = applyQwikComponentBody(ssr, jsx, type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove any type here?

@@ -21,7 +23,7 @@ Error.stackTraceLimit = 100;

describe.each([
{ render: ssrRenderToDom }, //
{ render: domRender }, //
{ render: domRender }, ///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove additional /

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting For Review
Development

Successfully merging this pull request may close these issues.

2 participants