Skip to content

Commit e2a394f

Browse files
committed
fix: ensure inorder loading content always wrapped in comment
1 parent 619cd6b commit e2a394f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/components/micro-frame/__tests__/__snapshots__/ssr-stream-loading.expected.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@
6363
</div>
6464
</div>
6565
<script>
66-
((e,t,d)=>{t=document.getElementById(e);do{t.removeChild(d=t.firstChild)}while(d.data!==e)})("s0-8-0");
66+
((e,t,d)=>{t=document.getElementById(e);do{t.removeChild(d=t.firstChild.nextSibling)}while(d.data!==e)})("s0-8-0");
6767
</script>
6868
```

src/node_modules/@internal/micro-frame-component/components/ssr-wait.marko

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<if(input.loading)>
55
<!-- Remove all of the <@loading> content after we've received all the data -->
66
$ out.script(
7-
`((e,t,d)=>{t=document.getElementById(e);do{t.removeChild(d=t.firstChild)}while(d.data!==e)})(${JSON.stringify(input.id)});`,
7+
`((e,t,d)=>{t=document.getElementById(e);do{t.removeChild(d=t.firstChild.nextSibling)}while(d.data!==e)})(${JSON.stringify(input.id)});`,
88
);
99
</if>
1010
</if>

src/node_modules/@internal/micro-frame-component/node.marko

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ static async function fetchBody(input, out, buffer) {
8686
}
8787

8888
<div id=component.id class=input.class style=input.style data-src=input.src>
89+
<if(input.loading && !input.clientReorder)>
90+
<!--
91+
We put the streamed html in a preserved fragment.
92+
This allows Marko to avoid diffing that section.
93+
-->
94+
$ out.bf("@b", component, true);
95+
<${input.loading}/>
96+
<!-- output a comment used as a marker to detect where the loading content starts so it can be removed -->$!{`<!--${component.id}-->`}
97+
$ out.ef();
98+
</if>
99+
89100
<!--
90101
We put the streamed html in a preserved fragment.
91102
This allows Marko to avoid diffing that section.
@@ -104,10 +115,6 @@ static async function fetchBody(input, out, buffer) {
104115
</await>
105116
</if>
106117
<else>
107-
<if(input.loading)>
108-
<${input.loading} key="b"/>
109-
<!-- output a comment used as a marker to detect where the loading content starts so it can be removed -->$!{`<!--${component.id}-->`}
110-
</if>
111118
<await(fetchBody(input, out, false))
112119
timeout=input.timeout
113120
catch=input.catch

0 commit comments

Comments
 (0)