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: calling component as a function #7057

Merged
merged 2 commits into from
Nov 12, 2024
Merged

Conversation

Varixo
Copy link
Member

@Varixo Varixo commented Nov 10, 2024

This PR fixes calling a component as a function by returning a jsxSplit with correct props inside component

Copy link

changeset-bot bot commented Nov 10, 2024

⚠️ No Changeset found

Latest commit: 3c441f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

pkg-pr-new bot commented Nov 10, 2024

Open in Stackblitz

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

commit: 3c441f6

Copy link
Contributor

github-actions bot commented Nov 10, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 3c441f6

@shairez
Copy link
Contributor

shairez commented Nov 12, 2024

@ianlet thank you for reviewing
we'll merge this but if you find any other cases where this is not working, please let us know and link to the issue, thanks!

@shairez shairez merged commit a261e1b into build/v2 Nov 12, 2024
19 checks passed
@shairez shairez deleted the fix-call-component-as-fn branch November 12, 2024 19:35
Comment on lines +447 to +449
<div>
bar: <div id="1">Test</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

oh this shouldn't be here 😮 that's why this test is passing

with this rendered content, the expected vNode should be:

      <InlineComponent>
        <Component>
          <div>
            bar: 
            <div>
              bar: <div id="1">Test</div>
            </div>
          </div>
        </Component>
      </InlineComponent>

and not the one below.

Here, try with this test instead:

  it('should render component$ inside inlined wrapper', async () => {
    interface ComplexWrapperProps {
      foo: string;
    }

    const ComplexWrapper = (
      props: PublicProps<ComplexWrapperProps>,
      key: string | null,
      flags: number
    ) => {
      const cmpFn = component$<ComplexWrapperProps>(({ foo }) => {
        return (
          <div>
            {foo}: <Slot />
          </div>
        );
      });
      return cmpFn(props, key, flags);
    };

    const { vNode } = await render(<ComplexWrapper foo="bar">Test</ComplexWrapper>, { debug });

    expect(vNode).toMatchVDOM(
      <InlineComponent>
        <Component>
          <div>bar: Test</div>
        </Component>
      </InlineComponent>
    );
  });

This should fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @ianlet

@Varixo do you know how to fix this?

Copy link
Member Author

Choose a reason for hiding this comment

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

not yet :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants