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


TypeScript IDOM.createTemplate方法代码示例

本文整理汇总了TypeScript中@aurelia/runtime.IDOM.createTemplate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IDOM.createTemplate方法的具体用法?TypeScript IDOM.createTemplate怎么用?TypeScript IDOM.createTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@aurelia/runtime.IDOM的用法示例。


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

示例1: processTemplateControllers

/**
 * A (temporary) standalone function that purely does the DOM processing (lifting) related to template controllers.
 * It's a first refactoring step towards separating DOM parsing/binding from mutations.
 */
function processTemplateControllers(dom: IDOM, manifestProxy: IParentNodeSymbol, manifest: IElementSymbol): void {
  const manifestNode = manifest.physicalNode as HTMLElement;
  let current = manifestProxy as TemplateControllerSymbol;
  let currentTemplate: HTMLTemplateElement;
  while ((current as IParentNodeSymbol) !== manifest) {
    if (current.template === manifest) {
      // the DOM linkage is still in its original state here so we can safely assume the parentNode is non-null
      manifestNode.parentNode.replaceChild(current.marker as Node, manifestNode);

      // if the manifest is a template element (e.g. <template repeat.for="...">) then we can skip one lift operation
      // and simply use the template directly, saving a bit of work
      if (manifestNode.nodeName === 'TEMPLATE') {
        current.physicalNode = manifestNode as HTMLTemplateElement;
        // the template could safely stay without affecting anything visible, but let's keep the DOM tidy
        manifestNode.remove();
      } else {
        // the manifest is not a template element so we need to wrap it in one
        currentTemplate = current.physicalNode = dom.createTemplate() as HTMLTemplateElement;
        currentTemplate.content.appendChild(manifestNode);
      }
    } else {
      currentTemplate = current.physicalNode = dom.createTemplate() as HTMLTemplateElement;
      currentTemplate.content.appendChild(current.marker as Node);
    }
    manifestNode.removeAttribute(current.syntax.rawName);
    current = current.template as TemplateControllerSymbol;
  }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:32,代码来源:template-binder.ts

示例2: processReplacePart

function processReplacePart(dom: IDOM, replacePart: ReplacePartSymbol, manifestProxy: IParentNodeSymbol | ISymbolWithMarker): void {
    let proxyNode: HTMLElement;
    let currentTemplate: HTMLTemplateElement;
    if (manifestProxy.flags & SymbolFlags.hasMarker) {
      proxyNode = (manifestProxy as ISymbolWithMarker).marker as HTMLElement;
    } else {
      proxyNode = manifestProxy.physicalNode as HTMLElement;
    }
    if (proxyNode.nodeName === 'TEMPLATE') {
      // if it's a template element, no need to do anything special, just assign it to the replacePart
      replacePart.physicalNode = proxyNode as HTMLTemplateElement;
    } else {
      // otherwise wrap the replace-part in a template
      currentTemplate = replacePart.physicalNode = dom.createTemplate() as HTMLTemplateElement;
      currentTemplate.content.appendChild(proxyNode);
    }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:17,代码来源:template-binder.ts


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