本文整理汇总了TypeScript中@aurelia/runtime.IExpressionParser类的典型用法代码示例。如果您正苦于以下问题:TypeScript IExpressionParser类的具体用法?TypeScript IExpressionParser怎么用?TypeScript IExpressionParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IExpressionParser类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: bindLetElement
private bindLetElement(parentManifest: IElementSymbol, node: HTMLElement): void {
const symbol = new LetElementSymbol(this.dom, node);
parentManifest.childNodes.push(symbol);
const attributes = node.attributes;
let i = 0;
while (i < attributes.length) {
const attr = attributes[i];
if (attr.name === 'to-view-model') {
node.removeAttribute('to-view-model');
symbol.toViewModel = true;
continue;
}
const attrSyntax = this.attrParser.parse(attr.name, attr.value);
const command = this.resources.getBindingCommand(attrSyntax);
const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
const to = PLATFORM.camelCase(attrSyntax.target);
const info = new BindableInfo(to, BindingMode.toView);
symbol.bindings.push(new BindingSymbol(command, info, expr, attrSyntax.rawValue, to));
++i;
}
node.parentNode.replaceChild(symbol.marker as Node, node);
}
开发者ID:aurelia,项目名称:aurelia,代码行数:25,代码来源:template-binder.ts
示例2: bindText
private bindText(node: Text): ChildNode {
if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bindText', slice.call(arguments)); }
const interpolation = this.exprParser.parse(node.wholeText, BindingType.Interpolation);
if (interpolation !== null) {
const symbol = new TextSymbol(this.dom, node, interpolation);
this.manifest.childNodes.push(symbol);
processInterpolationText(symbol);
}
while (node.nextSibling !== null && node.nextSibling.nodeType === NodeType.Text) {
node = node.nextSibling as Text;
}
if (Tracer.enabled) { Tracer.leave(); }
return node;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:14,代码来源:template-binder.ts
示例3: bindPlainAttribute
private bindPlainAttribute(attrSyntax: AttrSyntax, attr: Attr): void {
if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bindPlainAttribute', slice.call(arguments)); }
if (attrSyntax.rawValue.length === 0) {
if (Tracer.enabled) { Tracer.leave(); }
return;
}
const command = this.resources.getBindingCommand(attrSyntax);
const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
const manifest = this.manifest;
const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
if (manifest.flags & SymbolFlags.isCustomElement) {
const bindable = (manifest as CustomElementSymbol).bindables[attrSyntax.target];
if (bindable !== undefined) {
// if the attribute name matches a bindable property name, add it regardless of whether it's a command, interpolation, or just a plain string;
// the template compiler will translate it to the correct instruction
(manifest as CustomElementSymbol).bindings.push(new BindingSymbol(command, bindable, expr, attrSyntax.rawValue, attrSyntax.target));
manifest.isTarget = true;
} else if (expr !== null || attrSyntax.target === 'ref') {
// if it does not map to a bindable, only add it if we were able to parse an expression (either a command or interpolation)
manifest.attributes.push(new PlainAttributeSymbol(attrSyntax, command, expr));
manifest.isTarget = true;
}
} else if (expr !== null || attrSyntax.target === 'ref') {
// either a binding command, an interpolation, or a ref
manifest.attributes.push(new PlainAttributeSymbol(attrSyntax, command, expr));
manifest.isTarget = true;
} else if (manifest === this.surrogate) {
// any attributes, even if they are plain (no command/interpolation etc), should be added if they
// are on the surrogate element
manifest.attributes.push(new PlainAttributeSymbol(attrSyntax, command, expr));
}
if (command === null && expr !== null) {
// if it's an interpolation, clear the attribute value
attr.value = '';
}
if (Tracer.enabled) { Tracer.leave(); }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:42,代码来源:template-binder.ts
示例4: declareTemplateController
private declareTemplateController(attrSyntax: AttrSyntax, attrInfo: AttrInfo): TemplateControllerSymbol {
if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'declareTemplateController', slice.call(arguments)); }
let symbol: TemplateControllerSymbol;
// dynamicOptions logic here is similar to (and explained in) bindCustomAttribute
const command = this.resources.getBindingCommand(attrSyntax);
if (command === null && attrInfo.hasDynamicOptions) {
symbol = new TemplateControllerSymbol(this.dom, attrSyntax, attrInfo, this.partName);
this.partName = null;
this.bindMultiAttribute(symbol, attrInfo, attrSyntax.rawValue);
} else {
symbol = new TemplateControllerSymbol(this.dom, attrSyntax, attrInfo, this.partName);
const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
symbol.bindings.push(new BindingSymbol(command, attrInfo.bindable, expr, attrSyntax.rawValue, attrSyntax.target));
this.partName = null;
}
if (Tracer.enabled) { Tracer.leave(); }
return symbol;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:21,代码来源:template-binder.ts
示例5: bindMultiAttribute
private bindMultiAttribute(symbol: IResourceAttributeSymbol, attrInfo: AttrInfo, value: string): void {
if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bindMultiAttribute', slice.call(arguments)); }
const attributes = parseMultiAttributeBinding(value);
let attr: IAttrLike;
for (let i = 0, ii = attributes.length; i < ii; ++i) {
attr = attributes[i];
const attrSyntax = this.attrParser.parse(attr.name, attr.value);
const command = this.resources.getBindingCommand(attrSyntax);
const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
let bindable = attrInfo.bindables[attrSyntax.target];
if (bindable === undefined) {
// everything in a dynamicOptions expression must be used, so if it's not a bindable then we create one on the spot
bindable = attrInfo.bindables[attrSyntax.target] = new BindableInfo(attrSyntax.target, BindingMode.toView);
}
symbol.bindings.push(new BindingSymbol(command, bindable, expr, attrSyntax.rawValue, attrSyntax.target));
}
if (Tracer.enabled) { Tracer.leave(); }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:22,代码来源:template-binder.ts
示例6: bindCustomAttribute
private bindCustomAttribute(attrSyntax: AttrSyntax, attrInfo: AttrInfo): void {
if (Tracer.enabled) { Tracer.enter('TemplateBinder', 'bindCustomAttribute', slice.call(arguments)); }
const command = this.resources.getBindingCommand(attrSyntax);
let symbol: CustomAttributeSymbol;
if (command === null && attrInfo.hasDynamicOptions) {
// a dynamicOptions (semicolon separated binding) is only valid without a binding command;
// the binding commands must be declared in the dynamicOptions expression itself
symbol = new CustomAttributeSymbol(attrSyntax, attrInfo);
this.bindMultiAttribute(symbol, attrInfo, attrSyntax.rawValue);
} else {
// we've either got a command (with or without dynamicOptions, the latter maps to the first bindable),
// or a null command but without dynamicOptions (which may be an interpolation or a normal string)
symbol = new CustomAttributeSymbol(attrSyntax, attrInfo);
const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
symbol.bindings.push(new BindingSymbol(command, attrInfo.bindable, expr, attrSyntax.rawValue, attrSyntax.target));
}
this.manifest.attributes.push(symbol);
this.manifest.isTarget = true;
if (Tracer.enabled) { Tracer.leave(); }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:23,代码来源:template-binder.ts
注:本文中的@aurelia/runtime.IExpressionParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论