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


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

本文整理汇总了TypeScript中slim-dom.diffNode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript diffNode函数的具体用法?TypeScript diffNode怎么用?TypeScript diffNode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了diffNode函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: prepDiff

const patchNodeAndDOM = (oldNode: SlimParentNode, newNode: SlimParentNode, mount: HTMLElement, map: NativeObjectMap) => {
  const diffs = prepDiff(oldNode, diffNode(oldNode, newNode));
  for (const mutation of diffs) {
    map = patchDOM2(mutation, oldNode, mount, map);
    oldNode = patchNode2(mutation, oldNode);
  }

  return { node: oldNode, map };
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:9,代码来源:dom-render2-test.ts

示例2: it

    it(`can diff ${oldSource} against ${newSource}`, async () => {
      const { graph: ag } = await loadModuleDependencyGraph("entry.pc", {
        readFile: () => Promise.resolve(wrapSource(oldSource))
      });
      const { graph: bg } =  await loadModuleDependencyGraph("entry.pc", {
        readFile: () => Promise.resolve(wrapSource(newSource))
      });

      const { document: an } = runPCFile({ entry: {filePath: "entry.pc", componentId: "entry", previewName: "main" }, graph: ag });

      const { document: bn, diagnostics } = runPCFile({ entry: {filePath: "entry.pc", componentId: "entry", previewName: "main" }, graph: bg });

      const diffs = diffNode(an, bn);
      expect(diffs).to.eql(expectedDiffs);
    });
开发者ID:cryptobuks,项目名称:tandem,代码行数:15,代码来源:vm-diff-patch-test.ts

示例3: getComponentJSONPreviewDiff

function* getComponentJSONPreviewDiff(req: express.Request, res: express.Response, next) {
  const state: ApplicationState = yield select();
  const { componentId, previewName, oldChecksum, newChecksum } = req.params;
  const oldDocument = getPreviewDocumentByChecksum(componentId, previewName, oldChecksum, state);
  const newDocument = getPreviewDocumentByChecksum(componentId, previewName, newChecksum, state);

  if (!oldDocument) {
    return next();
  }

  if (!newDocument) {
    return next();
  }

  return res.send(diffNode(oldDocument, newDocument));
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:16,代码来源:api.ts

示例4: evaluatePreviews

function* evaluatePreviews(graph: DependencyGraph, sourceUri: string) {
  const state: ApplicationState = yield select();
  const moduleSourceDirectory = getModuleSourceDirectory(state);
  for (const filePath in graph) {
    const dep = graph[filePath];
    if (sourceUri && sourceUri !== filePath && values(dep.resolvedImportUris).indexOf(sourceUri) === -1) {
      continue;
    }

    const { module } = dep;
    if (module.type === PCModuleType.COMPONENT) {
      for (const component of (module as ComponentModule).components) {
        for (const preview of component.previews) {
          const entry = {
            componentId: component.id,
            filePath,
            previewName: preview.name
          }
    
          const { document } = runPCFile({ entry, graph, directoryAliases: {

            // TODO - will eventually want to pass host and protocol information here too
            [moduleSourceDirectory]: `http://localhost:${state.options.port}${PUBLIC_SRC_DIR_PATH}`
          } });
          const prevDocument = getLatestPreviewDocument(component.id, preview.name, yield select());
          
          console.log(`Evaluated component ${component.id}:${preview.name}`);

          let newDocument = document as SlimParentNode;

          // TODO - push diagnostics too
          yield put(previewEvaluated(component.id, preview.name, newDocument));

          if (prevDocument) {
            const diff = diffNode(prevDocument, newDocument);

            // push even if there are no diffs so that FE can flag windows as loaded.
            yield put(previewDiffed(component.id, preview.name, getDocumentChecksum(prevDocument), diff));
          }
        }
      }
    }
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:44,代码来源:uri-watcher.ts


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