formacao
This commit is contained in:
+10
-8
@@ -4,7 +4,7 @@ import { HtmlEscapedCallbackPhase, resolveCallback } from "../utils/html.js";
|
||||
import { JSXNode } from "./base.js";
|
||||
import { childrenToString } from "./components.js";
|
||||
import { DOM_RENDERER, DOM_STASH } from "./constants.js";
|
||||
import { createContext, useContext } from "./context.js";
|
||||
import { captureRenderContext, createContext, useContext } from "./context.js";
|
||||
import { Suspense as SuspenseDomRenderer } from "./dom/components.js";
|
||||
import { buildDataStack } from "./dom/render.js";
|
||||
var StreamingContext = createContext(null);
|
||||
@@ -19,9 +19,8 @@ var Suspense = async ({
|
||||
const nonce = useContext(StreamingContext)?.scriptNonce;
|
||||
let resArray = [];
|
||||
const stackNode = { [DOM_STASH]: [0, []] };
|
||||
const popNodeStack = (value) => {
|
||||
const popNodeStack = () => {
|
||||
buildDataStack.pop();
|
||||
return value;
|
||||
};
|
||||
try {
|
||||
stackNode[DOM_STASH][0] = 0;
|
||||
@@ -31,12 +30,15 @@ var Suspense = async ({
|
||||
);
|
||||
} catch (e) {
|
||||
if (e instanceof Promise) {
|
||||
const resume = captureRenderContext();
|
||||
resArray = [
|
||||
e.then(() => {
|
||||
stackNode[DOM_STASH][0] = 0;
|
||||
buildDataStack.push([[], stackNode]);
|
||||
return childrenToString(children).then(popNodeStack);
|
||||
})
|
||||
e.then(
|
||||
() => resume(() => {
|
||||
stackNode[DOM_STASH][0] = 0;
|
||||
buildDataStack.push([[], stackNode]);
|
||||
return childrenToString(children).finally(popNodeStack);
|
||||
})
|
||||
)
|
||||
];
|
||||
} else {
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user