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


TypeScript ResourceModel.getAttributeInfo方法代码示例

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


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

示例1: bind

  public bind(node: HTMLTemplateElement): PlainElementSymbol {
    if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bind', slice.call(arguments)); }
    if (Profiler.enabled) { enter(); }

    const surrogateSave = this.surrogate;
    const parentManifestRootSave = this.parentManifestRoot;
    const manifestRootSave = this.manifestRoot;
    const manifestSave = this.manifest;

    const manifest = this.surrogate = this.manifest = new PlainElementSymbol(node);

    const attributes = node.attributes;
    let i = 0;
    while (i < attributes.length) {
      const attr = attributes[i];
      const attrSyntax = this.attrParser.parse(attr.name, attr.value);

      if (invalidSurrogateAttribute[attrSyntax.target] === true) {
        if (Profiler.enabled) { leave(); }
        throw new Error(`Invalid surrogate attribute: ${attrSyntax.target}`);
        // TODO: use reporter
      }
      const attrInfo = this.resources.getAttributeInfo(attrSyntax);
      if (attrInfo === null) {
        this.bindPlainAttribute(attrSyntax, attr);
      } else if (attrInfo.isTemplateController) {
        if (Profiler.enabled) { leave(); }
        throw new Error('Cannot have template controller on surrogate element.');
        // TODO: use reporter
      } else {
        this.bindCustomAttribute(attrSyntax, attrInfo);
      }
      ++i;
    }

    this.bindChildNodes(node);

    this.surrogate = surrogateSave;
    this.parentManifestRoot = parentManifestRootSave;
    this.manifestRoot = manifestRootSave;
    this.manifest = manifestSave;

    if (Profiler.enabled) { leave(); }
    if (Tracer.enabled) { Tracer.leave(); }
    return manifest;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:46,代码来源:template-binder.ts

示例2: bindAttributes

  private bindAttributes(node: HTMLTemplateElement | HTMLElement, parentManifest: IElementSymbol): void {
    if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bindAttributes', slice.call(arguments)); }

    const { parentManifestRoot, manifestRoot, manifest } = this;
    // This is the top-level symbol for the current depth.
    // If there are no template controllers or replace-parts, it is always the manifest itself.
    // If there are template controllers, then this will be the outer-most TemplateControllerSymbol.
    let manifestProxy: IParentNodeSymbol = manifest;

    const replacePart = this.declareReplacePart(node);

    let previousController: TemplateControllerSymbol;
    let currentController: TemplateControllerSymbol;

    const attributes = node.attributes;
    let i = 0;
    while (i < attributes.length) {
      const attr = attributes[i];
      ++i;
      if (attributesToIgnore[attr.name] === true) {
        continue;
      }
      const attrSyntax = this.attrParser.parse(attr.name, attr.value);
      const attrInfo = this.resources.getAttributeInfo(attrSyntax);

      if (attrInfo === null) {
        // it's not a custom attribute but might be a regular bound attribute or interpolation (it might also be nothing)
        this.bindPlainAttribute(attrSyntax, attr);
      } else if (attrInfo.isTemplateController) {
        // the manifest is wrapped by the inner-most template controller (if there are multiple on the same element)
        // so keep setting manifest.templateController to the latest template controller we find
        currentController = manifest.templateController = this.declareTemplateController(attrSyntax, attrInfo);

        // the proxy and the manifest are only identical when we're at the first template controller (since the controller
        // is assigned to the proxy), so this evaluates to true at most once per node
        if (manifestProxy === manifest) {
          currentController.template = manifest;
          manifestProxy = currentController;
        } else {
          currentController.templateController = previousController;
          currentController.template = previousController.template;
          previousController.template = currentController;
        }
        previousController = currentController;
      } else {
        // a regular custom attribute
        this.bindCustomAttribute(attrSyntax, attrInfo);
      }
    }

    processTemplateControllers(this.dom, manifestProxy, manifest);

    if (replacePart === null) {
      // the proxy is either the manifest itself or the outer-most controller; add it directly to the parent
      parentManifest.childNodes.push(manifestProxy);
    } else {
      // there is a replace-part attribute on this node, so add it to the parts collection of the manifestRoot
      // instead of to the childNodes
      replacePart.parent = parentManifest;
      replacePart.template = manifestProxy;

      // if the current manifest is also the manifestRoot, it means the replace-part sits on a custom
      // element, so add the part to the parent wrapping custom element instead
      const partOwner = manifest === manifestRoot ? parentManifestRoot : manifestRoot;
      partOwner.parts.push(replacePart);

      processReplacePart(this.dom, replacePart, manifestProxy);
    }

    if (Tracer.enabled) { Tracer.leave(); }
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:71,代码来源:template-binder.ts


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