feat: change suspense event id (#7057)

* feat: change suspense event id

* chore: add missing change set
This commit is contained in:
Keith 2025-03-07 11:27:17 +08:00 committed by GitHub
parent 15cd5f7f6f
commit a0099df51e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---
feat: post event for each suspense.

View File

@ -0,0 +1,5 @@
---
'@ice/bundles': patch
---
fix: update es-module-lexer

View File

@ -11,7 +11,7 @@ export default function Home() {
<h2>Home Page</h2>
<Counter />
<Comments id="comments" fallback={<div>loading...</div>} />
<Footer id="comments" fallback={<div>loading...</div>} />
<Footer id="comments-2" fallback={<div>loading...</div>} />
</div>
);
}

View File

@ -158,7 +158,7 @@ export function withSuspense(Component) {
<Data id={id} />
<script
dangerouslySetInnerHTML={{
__html: `window.dispatchEvent(new CustomEvent('ice-suspense', { detail: { id: '${id}' } }));`,
__html: `window.dispatchEvent(new CustomEvent('ice-suspense', { detail: { id: ${id ? `'${id}'` : undefined} } }));`,
}}
/>
</SuspenseContext.Provider>
@ -172,11 +172,9 @@ function Data(props) {
return (
<script
id={props.id ? `suspenseScript:${props.id}` : ''}
id={props.id && `suspense-script-${props.id}`}
dangerouslySetInnerHTML={{
__html: `!function(){window['${LOADER}'] = window['${LOADER}'] || {};window['${LOADER}']['${
props.id
}'] = ${JSON.stringify(data)}}();`,
__html: `!function(){window['${LOADER}'] = window['${LOADER}'] || {};window['${LOADER}']['${props.id}'] = ${JSON.stringify(data)}}();`,
}}
/>
);