本文整理匯總了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;
}
示例2:
templateDefinitionArrays.forEach(prop => {
if (nameOrDef[prop]) {
def[prop] = PLATFORM.toArray(nameOrDef[prop]);
}
});
示例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;
}