You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix bug with (injected) custom elements and layouts
This fixes a bug, uncovered in #2112 and in #2123,
which is rather unlikely to occur.
It only occurs when:
1. Custom elements (such as `<a-b></a-b>`) are injected (not authored)
into a tree
2. Either:
1. A layout component is defined within an MDX document
2. A provider is used, and any component is defined within MDX
documents
In those cases, an accidental `const ;` was injected into the final
serialized document.
Which caused anything trying to run the code to crash.
The problem was introduced in 9904838, the commit message of which
sheds some light on why custom elements are peculiar and need extra
handling.
We track which component contains which other components.
If some component uses `<A />`, then some code to handle `A` is
injected in that component.
If a different component uses `<B />`, some code for `B` is injected
inside it.
But the components don’t need to know about what’s used in other
components.
This mechanism had a mistake for custom elements: they were tracked
globally.
This commit fixes that, by tracking them scoped to the component that
includes them.
Related-to: GH-2100.
Related-to: GH-2101.
ClosesGH-2112.
ClosesGH-2123.
Co-authored-by: Caleb Eby <caleb.eby01@gmail.com>
Co-authored-by: bholmesdev <hey@bholmes.dev>
1 commit comments
vercel[bot] commentedon Oct 11, 2022
Successfully deployed to the following URLs:
mdx – ./
mdx-mdx.vercel.app
mdx-git-main-mdx.vercel.app
mdxjs.com
v2.mdxjs.com