summaryrefslogtreecommitdiff
path: root/packages/markdown/remark/src
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-06-15 08:50:05 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-15 08:50:05 -0400
commitfc52321a888920beebb6b84f56d2f41791666e13 (patch)
tree7e2985d711457a586bc0239a766de9841ac86069 /packages/markdown/remark/src
parenta7637e6b26c97497cf6de7088d0b3cdfb03eee8d (diff)
downloadastro-fc52321a888920beebb6b84f56d2f41791666e13.tar.gz
astro-fc52321a888920beebb6b84f56d2f41791666e13.tar.zst
astro-fc52321a888920beebb6b84f56d2f41791666e13.zip
Consolidate hydration scripts into just one (#3571)
* Remove redundant hydration scripts * Prebuild the island JS * Fix build * Updates to tests * Update more references * Custom element test now has two classic scripts * Account for non-default exports * Restructure hydration directives * Move nested logic into the island component * Remove try/catch
Diffstat (limited to 'packages/markdown/remark/src')
-rw-r--r--packages/markdown/remark/src/rehype-islands.ts6
-rw-r--r--packages/markdown/remark/src/remark-unwrap.ts6
2 files changed, 6 insertions, 6 deletions
diff --git a/packages/markdown/remark/src/rehype-islands.ts b/packages/markdown/remark/src/rehype-islands.ts
index bbd584792..a8b78848d 100644
--- a/packages/markdown/remark/src/rehype-islands.ts
+++ b/packages/markdown/remark/src/rehype-islands.ts
@@ -9,14 +9,14 @@ const visit = _visit as (
) => any;
// This fixes some confusing bugs coming from somewhere inside of our Markdown pipeline.
-// `unist`/`remark`/`rehype` (not sure) often generate malformed HTML inside of <astro-root>
+// `unist`/`remark`/`rehype` (not sure) often generate malformed HTML inside of <astro-island>
// For hydration to work properly, frameworks need the DOM to be the exact same on server/client.
// This reverts some "helpful corrections" that are applied to our perfectly valid HTML!
export default function rehypeIslands(): any {
return function (node: any): any {
return visit(node, 'element', (el) => {
- // Bugs only happen inside of <astro-root> islands
- if (el.tagName == 'astro-root') {
+ // Bugs only happen inside of <astro-island> islands
+ if (el.tagName == 'astro-island') {
visit(el, 'text', (child, index, parent) => {
if (child.type === 'text') {
// Sometimes comments can be trapped as text, which causes them to be escaped
diff --git a/packages/markdown/remark/src/remark-unwrap.ts b/packages/markdown/remark/src/remark-unwrap.ts
index e54f01397..399bd6cd6 100644
--- a/packages/markdown/remark/src/remark-unwrap.ts
+++ b/packages/markdown/remark/src/remark-unwrap.ts
@@ -8,7 +8,7 @@ const visit = _visit as (
callback?: (node: any, index: number, parent: any) => any
) => any;
-// Remove the wrapping paragraph for <astro-root> islands
+// Remove the wrapping paragraph for <astro-island> islands
export default function remarkUnwrap() {
const astroRootNodes = new Set();
let insideAstroRoot = false;
@@ -19,10 +19,10 @@ export default function remarkUnwrap() {
astroRootNodes.clear();
visit(tree, 'html', (node) => {
- if (node.value.indexOf('<astro-root') > -1 && !insideAstroRoot) {
+ if (node.value.indexOf('<astro-island') > -1 && !insideAstroRoot) {
insideAstroRoot = true;
}
- if (node.value.indexOf('</astro-root') > -1 && insideAstroRoot) {
+ if (node.value.indexOf('</astro-island') > -1 && insideAstroRoot) {
insideAstroRoot = false;
}
astroRootNodes.add(node);