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


TypeScript PLATFORM.toArray方法代码示例

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


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

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

示例2:

 templateDefinitionArrays.forEach(prop => {
   if (nameOrDef[prop]) {
     def[prop] = PLATFORM.toArray(nameOrDef[prop]);
   }
 });
开发者ID:aurelia,项目名称:aurelia,代码行数:5,代码来源:definitions.ts

示例3: buildTemplateDefinition

export function buildTemplateDefinition(
  ctor: CustomElementConstructor | null,
  nameOrDef: string | Immutable<ITemplateDefinition> | null,
  template?: unknown | null,
  cache?: number | '*' | null,
  build?: IBuildInstruction | boolean | null,
  bindables?: Record<string, IBindableDescription> | null,
  instructions?: ReadonlyArray<ReadonlyArray<ITargetedInstruction>> | null,
  dependencies?: ReadonlyArray<IRegistry> | null,
  surrogates?: ReadonlyArray<ITargetedInstruction> | null,
  containerless?: boolean | null,
  shadowOptions?: { mode: 'open' | 'closed' } | null,
  hasSlots?: boolean | null,
  strategy?: BindingStrategy | null): TemplateDefinition {

  const def = new DefaultTemplateDefinition();

  // all cases fall through intentionally
  const argLen = arguments.length;
  switch (argLen) {
    case 13: if (strategy !== null) def.strategy = ensureValidStrategy(strategy);
    case 12: if (hasSlots !== null) def.hasSlots = hasSlots;
    case 11: if (shadowOptions !== null) def.shadowOptions = shadowOptions;
    case 10: if (containerless !== null) def.containerless = containerless;
    case 9: if (surrogates !== null) def.surrogates = PLATFORM.toArray(surrogates);
    case 8: if (dependencies !== null) def.dependencies = PLATFORM.toArray(dependencies);
    case 7: if (instructions !== null) def.instructions = PLATFORM.toArray(instructions) as ITargetedInstruction[][];
    case 6: if (bindables !== null) def.bindables = { ...bindables };
    case 5: if (build !== null) def.build = build === true ? buildRequired : build === false ? buildNotRequired : { ...build };
    case 4: if (cache !== null) def.cache = cache;
    case 3: if (template !== null) def.template = template;
    case 2:
      if (ctor !== null) {
        if (ctor['bindables']) {
          def.bindables = Bindable.for(ctor as unknown as {}).get();
        }
        if (ctor['containerless']) {
          def.containerless = ctor.containerless;
        }
        if (ctor['shadowOptions']) {
          def.shadowOptions = ctor.shadowOptions as unknown as { mode: 'open' | 'closed' };
        }
      }
      if (typeof nameOrDef === 'string') {
        if (nameOrDef.length > 0) {
          def.name = nameOrDef;
        }
      } else if (nameOrDef !== null) {
        def.strategy = ensureValidStrategy(nameOrDef.strategy);
        templateDefinitionAssignables.forEach(prop => {
          if (nameOrDef[prop]) {
            def[prop] = nameOrDef[prop];
          }
        });
        templateDefinitionArrays.forEach(prop => {
          if (nameOrDef[prop]) {
            def[prop] = PLATFORM.toArray(nameOrDef[prop]);
          }
        });
        if (nameOrDef['bindables']) {
          if (def.bindables === PLATFORM.emptyObject) {
            def.bindables = Bindable.for(nameOrDef as unknown as {}).get();
          } else {
            Object.assign(def.bindables, nameOrDef.bindables);
          }
        }
      }
  }

  // special handling for invocations that quack like a @customElement decorator
  if (argLen === 2 && ctor !== null && (typeof nameOrDef === 'string' || !('build' in nameOrDef))) {
    def.build = buildRequired;
  }

  return def;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:76,代码来源:definitions.ts


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