本文整理匯總了TypeScript中slim-dom.renderDOM2函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript renderDOM2函數的具體用法?TypeScript renderDOM2怎麽用?TypeScript renderDOM2使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了renderDOM2函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
const diffPatchVariants = async (variants: string[]) => {
const fakeDocument = new FakeDocument();
const body = fakeDocument.createElement("body");
let map: any;
let currentDocument: SlimParentNode;
for (const variant of variants) {
const newDocument = await runPCComponent({
"entry.pc": variant
});
if (!currentDocument) {
currentDocument = setVMObjectIds(newDocument, "item");
map = renderDOM2(currentDocument, body as any);
} else {
const result = patchNodeAndDOM(currentDocument, newDocument, body as any, map);
currentDocument = result.node;
map = result.map;
const expBody = fakeDocument.createElement("body");
renderDOM2(newDocument, expBody as any);
expect(body.toString()).to.eql(expBody.toString());
}
}
}
示例2: it
it(`can render a component with named slots`, async () => {
const document = new FakeDocument();
const body = document.createElement("body");
const slimDoc = await runPCComponent({
"entry.pc": `
<component id="test">
<template>
<span><slot></slot><slot name="a"></slot><slot name="b"></slot></span>
</template>
<preview name="main">
<test>a <span slot="a">b</span><span slot="b">c</span><span slot="b">d</span>e</test>
</preview>
</component>
`
});
renderDOM2(slimDoc, body as any);
expect(body.toString()).to.eql(`<body><test class="__test_scope_host"><span class="__test_scope"><!--section-start-->ae<!--section-end--><!--section-start--><span slot="a">b</span><!--section-end--><!--section-start--><span slot="b">c</span><span slot="b">d</span><!--section-end--></span></test></body>`);
});
示例3: emit
mount.addEventListener("load", () => {
emit(renderDOM2(doc, mount.contentDocument.body));
});