当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript slim-dom.renderDOM2函数代码示例

本文整理汇总了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());
    }
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:23,代码来源:dom-render2-test.ts

示例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>`);
 });
开发者ID:cryptobuks,项目名称:tandem,代码行数:18,代码来源:dom-render2-test.ts

示例3: emit

 mount.addEventListener("load", () => {
   emit(renderDOM2(doc, mount.contentDocument.body));
 });
开发者ID:cryptobuks,项目名称:tandem,代码行数:3,代码来源:artboard.ts


注:本文中的slim-dom.renderDOM2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。