本文整理汇总了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));
});