本文整理匯總了TypeScript中@aurelia/runtime.IDOM.makeTarget方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IDOM.makeTarget方法的具體用法?TypeScript IDOM.makeTarget怎麽用?TypeScript IDOM.makeTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@aurelia/runtime.IDOM
的用法示例。
在下文中一共展示了IDOM.makeTarget方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例2: 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);
}