當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。