本文整理汇总了TypeScript中@aurelia/kernel.PLATFORM类的典型用法代码示例。如果您正苦于以下问题:TypeScript PLATFORM类的具体用法?TypeScript PLATFORM怎么用?TypeScript PLATFORM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PLATFORM类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: createElementInfo
function createElementInfo(def: TemplateDefinition): ElementInfo {
const info = new ElementInfo(def.name, def.containerless);
const bindables = def.bindables;
const defaultBindingMode = BindingMode.toView;
let bindable: IBindableDescription;
let prop: string;
let attr: string;
let mode: BindingMode;
for (prop in bindables) {
bindable = bindables[prop];
// explicitly provided property name has priority over the implicit property name
if (bindable.property !== undefined) {
prop = bindable.property;
}
// explicitly provided attribute name has priority over the derived implicit attribute name
if (bindable.attribute !== undefined) {
attr = bindable.attribute;
} else {
// derive the attribute name from the resolved property name
attr = PLATFORM.kebabCase(prop);
}
if (bindable.mode !== undefined && bindable.mode !== BindingMode.default) {
mode = bindable.mode;
} else {
mode = defaultBindingMode;
}
info.bindables[attr] = new BindableInfo(prop, mode);
}
return info;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:32,代码来源:resource-model.ts
示例3: verifyCalled
PLATFORM.requestAnimationFrame(() => {
obj1.foo = obj2.foo = `${++frameCount + 1}`;
verifyCalled(7);
PLATFORM.requestAnimationFrame(() => {
obj1.foo = obj2.foo = `${++frameCount + 1}`;
verifyCalled(8);
PLATFORM.requestAnimationFrame(() => {
obj1.foo = obj2.foo = `${++frameCount + 1}`;
verifyCalled(9);
PLATFORM.requestAnimationFrame(() => {
obj1.foo = obj2.foo = `${++frameCount + 1}`;
verifyCalled(10);
PLATFORM.requestAnimationFrame(() => {
obj1.foo = obj2.foo = `${++frameCount + 1}`;
verifyCalled(11);
observer1.unsubscribe(subscriber1);
observer1.unsubscribe(subscriber2);
observer2.unsubscribe(subscriber3);
observer2.unsubscribe(subscriber4);
done();
});
});
});
});
});
开发者ID:aurelia,项目名称:aurelia,代码行数:25,代码来源:dirty-checker.spec.ts
示例4: expect
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
observer.unsubscribe(subscriber);
done();
});
});
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:dirty-checker.spec.ts
示例5: getTarget
export function getTarget(binding: PlainAttributeSymbol | BindingSymbol, camelCase: boolean): string {
if (binding.flags & SymbolFlags.isBinding) {
return (binding as BindingSymbol).bindable.propName;
} else if (camelCase) {
return PLATFORM.camelCase((binding as PlainAttributeSymbol).syntax.target);
} else {
return (binding as PlainAttributeSymbol).syntax.target;
}
}
开发者ID:aurelia,项目名称:aurelia,代码行数:9,代码来源:binding-command.ts
示例6: 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
示例7: getAttributeInfo
/**
* Retrieve information about a custom attribute resource.
*
* @param syntax The parsed `AttrSyntax`
*
* @returns The resource information if the attribute exists, or `null` if it does not exist.
*/
public getAttributeInfo(syntax: AttrSyntax): AttrInfo | null {
const name = PLATFORM.camelCase(syntax.target);
let result = this.attributeLookup[name];
if (result === undefined) {
const def = this.resources.find(CustomAttributeResource, name);
if (def === null) {
result = null;
} else {
result = createAttributeInfo(def);
}
this.attributeLookup[name] = result;
}
return result;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:21,代码来源:resource-model.ts
示例8: it
it('does nothing if disabled', function(done) {
const framesPerCheck: number = 1;
DirtyCheckSettings.framesPerCheck = framesPerCheck;
DirtyCheckSettings.disabled = true;
const { dirtyChecker } = setup();
const obj = { foo: '0' };
const observer = dirtyChecker.createProperty(obj, 'foo');
let callCount: number = 0;
const subscriber = {
handleChange() {
++callCount;
}
};
observer.subscribe(subscriber);
obj.foo = `1`;
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
PLATFORM.requestAnimationFrame(() => {
expect(callCount).to.equal(0);
observer.unsubscribe(subscriber);
done();
});
});
});
});
});
});
开发者ID:aurelia,项目名称:aurelia,代码行数:40,代码来源:dirty-checker.spec.ts
示例9: it
it('is still true when a request is still in progress', function(done) {
const firstResponse = emptyResponse(200);
const secondResponse = new Promise((resolve) => {
PLATFORM.setTimeout(() => { resolve(emptyResponse(200)); }, 200);
});
fetch.onCall(0).returns(firstResponse);
fetch.onCall(1).returns(secondResponse);
expect(client.isRequesting, 'Before start').to.equal(false);
const request1 = client.fetch('http://example.com/some/cool/path');
const request2 = client.fetch('http://example.com/some/cool/path');
expect(client.isRequesting, 'When started').to.equal(true);
request1.then(() => {
expect(client.isRequesting, 'When request 1 is completed').to.equal(true);
}).catch(() => { done('Unexpected catch'); });
PLATFORM.setTimeout(() => { expect(client.isRequesting, 'After 100ms').to.equal(true); }, 100);
request2.then(() => {
expect(client.isRequesting, 'When all requests are finished').to.equal(false);
}).then(() => {
expect(fetch).to.have.callCount(2);
done();
}).catch(() => { done('Unexpected catch'); });
});
开发者ID:aurelia,项目名称:aurelia,代码行数:24,代码来源:http-client.spec.ts
注:本文中的@aurelia/kernel.PLATFORM类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论