-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix expression parsing in foreign context (#1062)
* fix(parser): persist the current namespace when adding an expression node * test: add printer test for `image` tag inside svg context * chore: add changeset
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrojs/compiler": patch | ||
--- | ||
|
||
Fixes an issue when parsing elements inside foreign content (e.g. SVG), when they were inside an expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
internal/printer/__printer_js__/namespace_is_preserved_when_inside_an_expression.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
[TestPrinter/namespace_is_preserved_when_inside_an_expression - 1] | ||
## Input | ||
|
||
``` | ||
<svg>{<image />}</svg> | ||
``` | ||
|
||
## Output | ||
|
||
```js | ||
import { | ||
Fragment, | ||
render as $$render, | ||
createAstro as $$createAstro, | ||
createComponent as $$createComponent, | ||
renderComponent as $$renderComponent, | ||
renderHead as $$renderHead, | ||
maybeRenderHead as $$maybeRenderHead, | ||
unescapeHTML as $$unescapeHTML, | ||
renderSlot as $$renderSlot, | ||
mergeSlots as $$mergeSlots, | ||
addAttribute as $$addAttribute, | ||
spreadAttributes as $$spreadAttributes, | ||
defineStyleVars as $$defineStyleVars, | ||
defineScriptVars as $$defineScriptVars, | ||
renderTransition as $$renderTransition, | ||
createTransitionScope as $$createTransitionScope, | ||
renderScript as $$renderScript, | ||
createMetadata as $$createMetadata | ||
} from "http://localhost:3000/"; | ||
|
||
export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); | ||
|
||
const $$Component = $$createComponent(($$result, $$props, $$slots) => { | ||
|
||
return $$render`${$$maybeRenderHead($$result)}<svg>${$$render`<image></image>`}</svg>`; | ||
}, undefined, undefined); | ||
export default $$Component; | ||
``` | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters