• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript runtime.IDOM类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RenderPlan

function createElementForTag<T extends INode>(dom: IDOM<T>, tagName: string, props?: Record<string, string | HTMLTargetedInstruction>, children?: ArrayLike<unknown>): RenderPlan<T> {
  if (Tracer.enabled) { Tracer.enter('createElement', 'createElementForTag', slice.call(arguments)); }
  const instructions: HTMLTargetedInstruction[] = [];
  const allInstructions: HTMLTargetedInstruction[][] = [];
  const dependencies: IRegistry[] = [];
  const element = dom.createElement(tagName);
  let hasInstructions = false;

  if (props) {
    Object.keys(props)
      .forEach(to => {
        const value = props[to];

        if (isHTMLTargetedInstruction(value)) {
          hasInstructions = true;
          instructions.push(value);
        } else {
          dom.setAttribute(element, to, value);
        }
      });
  }

  if (hasInstructions) {
    dom.makeTarget(element);
    allInstructions.push(instructions);
  }

  if (children) {
    addChildren(dom, element, children, allInstructions, dependencies);
  }

  if (Tracer.enabled) { Tracer.leave(); }
  return new RenderPlan(dom, element, allInstructions, dependencies);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:34,代码来源:create-element.ts


示例2: 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


示例3: HydrateElementInstruction

function createElementForType<T extends INode>(dom: IDOM<T>, Type: ICustomElementType<T>, props?: object, children?: ArrayLike<unknown>): RenderPlan<T> {
  if (Tracer.enabled) { Tracer.enter('createElement', 'createElementForType', slice.call(arguments)); }
  const tagName = Type.description.name;
  const instructions: HTMLTargetedInstruction[] = [];
  const allInstructions = [instructions];
  const dependencies: IRegistry[] = [];
  const childInstructions: HTMLTargetedInstruction[] = [];
  const bindables = Type.description.bindables;
  const element = dom.createElement(tagName);

  dom.makeTarget(element);

  if (!dependencies.includes(Type)) {
    dependencies.push(Type);
  }

  instructions.push(new HydrateElementInstruction(tagName, childInstructions));

  if (props) {
    Object.keys(props)
      .forEach(to => {
        const value: HTMLTargetedInstruction | string = props[to];

        if (isHTMLTargetedInstruction(value)) {
          childInstructions.push(value);
        } else {
          const bindable = bindables[to];

          if (bindable) {
            childInstructions.push({
              type: TargetedInstructionType.setProperty,
              to,
              value
            });
          } else {
            childInstructions.push(new SetAttributeInstruction(value, to));
          }
        }
      });
  }

  if (children) {
    addChildren(dom, element, children, allInstructions, dependencies);
  }

  if (Tracer.enabled) { Tracer.leave(); }
  return new RenderPlan<T>(dom, element, allInstructions, dependencies);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:48,代码来源:create-element.ts


示例4: switch

function addChildren<T extends INode>(dom: IDOM<T>, parent: T, children: ArrayLike<unknown>, allInstructions: HTMLTargetedInstruction[][], dependencies: IRegistry[]): void {
  for (let i = 0, ii = children.length; i < ii; ++i) {
    const current = children[i];

    switch (typeof current) {
      case 'string':
        dom.appendChild(parent, dom.createTextNode(current));
        break;
      case 'object':
        if (dom.isNodeInstance(current)) {
          dom.appendChild(parent, current);
        } else if ('mergeInto' in (current as RenderPlan)) {
          (current as RenderPlan<T>).mergeInto(parent, allInstructions, dependencies);
        }
    }
  }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:17,代码来源:create-element.ts


示例5: constructor

  constructor(dom: IDOM<Node>, $customElement: ICustomElement<Node>, host: Node) {
    if (host.childNodes.length) {
      this.childNodes = PLATFORM.toArray(host.childNodes);
    } else {
      this.childNodes = PLATFORM.emptyArray;
    }

    this.host = dom.convertToRenderLocation(host) as CustomElementHost<Node>;
    this.host.$customElement = $customElement;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:10,代码来源:projectors.ts


示例6: 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


示例7:

      .forEach(to => {
        const value = props[to];

        if (isHTMLTargetedInstruction(value)) {
          hasInstructions = true;
          instructions.push(value);
        } else {
          dom.setAttribute(element, to, value);
        }
      });
开发者ID:aurelia,项目名称:aurelia,代码行数:10,代码来源:create-element.ts


示例8: subscribeToChildrenChange

 public subscribeToChildrenChange(callback: () => void): void {
   // TODO: add a way to dispose/disconnect
   this.dom.createNodeObserver(this.shadowRoot, callback, childObserverOptions);
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:4,代码来源:projectors.ts


示例9: bind

 public bind(): void {
   this.nodeObserver = this.dom.createNodeObserver(this.obj, this.handleNodeChange.bind(this), childObserverOptions) as MutationObserver;
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:3,代码来源:select-value-observer.ts


示例10: mergeInto

 /** @internal */
 public mergeInto(parent: T, instructions: HTMLTargetedInstruction[][], dependencies: IRegistry[]): void {
   this.dom.appendChild(parent, this.node);
   instructions.push(...this.instructions);
   dependencies.push(...this.dependencies);
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:6,代码来源:create-element.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript runtime.IExpressionParser类代码示例发布时间:2022-05-28
下一篇:
TypeScript runtime.ICollectionObserver类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap