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

Add jsxFrag pragma, use fragment for shortcode warning #1394

Merged
merged 2 commits into from
Dec 20, 2020

Conversation

wooorm
Copy link
Member

@wooorm wooorm commented Dec 19, 2020

This adds a /* @jsxFrag mdx.Fragment */ next to the existing
/* @jsx mdx */ pragma.
From MDX runtimes, this exports as mdx.Fragment either React.Fragment
or Preact.Fragment.

Vue 2 does not support fragments, but as JSX and hence MDX is already
specific to React or Vue, well: folks shouldn’t use fragments in MDX
files targeting Vue.

As we have fragments, we can also use that to pass children through
missing components: <>{props.children}</>.
This fixes runtimes where HTML is not available, such as React Native.
But, as Vue doesn’t like that, there’s a hidden flag to still use
the original behavior: <div {...props} />.
Still, there remains a difference in frameworks: Vue does not put
children in props, so {...props} has never passed children along
in Vue.

Closes GH-972.
Closes GH-990.
Closes GH-1014.

@wooorm wooorm added 🦋 type/enhancement This is great to have 🙆 yes/confirmed This is confirmed and ready to be worked on 🗄 area/interface This affects the public interface 🧒 semver/minor This is backwards-compatible change labels Dec 19, 2020
@vercel
Copy link

vercel bot commented Dec 19, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/mdx/mdx/kuv4bjz5w
✅ Preview: Failed

[Deployment for d7a1473 failed]

@ChristianMurphy ChristianMurphy requested a review from a team December 19, 2020 16:17
@vercel vercel bot temporarily deployed to Preview December 20, 2020 10:03 Inactive
This adds a `/* @jsxFrag mdx.Fragment */` next to the existing
`/* @jsx mdx */` pragma.
From MDX runtimes, this exports as `mdx.Fragment` either `React.Fragment`
or `Preact.Fragment`.

Vue 2 does not support fragments, but as JSX and hence MDX is already
specific to React or Vue, well: folks shouldn’t use fragments in MDX
files targeting Vue.

As we have fragments, we can also use that to pass children through
missing components: `<>{props.children}</>`.
This fixes runtimes where HTML is not available, such as React Native.
But, as Vue doesn’t like that, there’s a hidden flag to still use
the original behavior: `<div {...props} />`.
Still, there remains a difference in frameworks: Vue does not put
`children` in `props`, so `{...props}` has never passed children along
in Vue.

Closes GH-972.
Closes GH-990.
Closes GH-1014.
@vercel vercel bot temporarily deployed to Preview December 20, 2020 15:18 Inactive
@wooorm wooorm merged commit e926974 into main Dec 20, 2020
@wooorm wooorm deleted the missing-shortcode-fragment branch December 20, 2020 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have 🙆 yes/confirmed This is confirmed and ready to be worked on
3 participants