當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。