本文整理汇总了TypeScript中@compo/exports.Compo函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Compo函数的具体用法?TypeScript Compo怎么用?TypeScript Compo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Compo函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: has_
has_(x, { foo: { name: 'Foo1' }});
done();
}, 300);
}
}));
renderer_render(`
import async * as X from '/test/tmpl/modules/data_foo_1.js';
TestAsync;
`);
},
'should await the component': {
'simple await' (done) {
customTag_define('TestAsync', Compo({
onRenderStart () {
var x = this.$scope('X');
has_(x, { foo: { name: 'Foo2' }});
done();
}
}));
renderer_render(`
import async * as X from '/test/tmpl/modules/data_foo_2.js';
await (X) > TestAsync;
`);
},
'progress await' (done) {
customTag_define('TestAsync', Compo({
onRenderStart () {
var x = this.$scope('X');
has_(x, { foo: { name: 'Foo3' }});
$(dom)
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:async.spec.ts
示例2: UTest
import { customTag_define } from '@core/custom/exports'
import { Compo } from '@compo/exports'
UTest({
'attributes': {
'components' : {
'should use parent as `this` in expressions' () {
customTag_define('Foo', Compo({
myNum: 5
}));
customTag_define('Bar', Compo({
myNum: 7
}));
var compo = Compo.initialize('Bar > Foo test=~[this.myNum] > div test="~[this.myNum]"');
var foo = compo.find('Foo');
is_(foo.attr.test, 'Number');
eq_(foo.attr.test, 7);
var divAttrVal = compo.$.filter('div').attr('test');
is_(divAttrVal, 'String');
eq_(divAttrVal, '5');
}
}
}
})
开发者ID:atmajs,项目名称:MaskJS,代码行数:25,代码来源:interpolations.spec.ts
示例3: UTest
import { customTag_define } from '@core/custom/tag';
import { renderer_render } from '@core/renderer/exports';
import { Compo } from '@compo/exports';
declare var sinon;
UTest({
'should set elements property' () {
let div = renderer_render(`
div
[style.position] = relative
[style.borderTopWidth] = 2em
;
`);
eq_(div.style.position, 'relative');
eq_(div.style.borderTopWidth, '2em');
},
'should set components properties' () {
let fn = sinon.spy(function(model){
eq_(this.a.b.c, 'd');
});
customTag_define('Foo', Compo({
onRenderStart: fn
}))
renderer_render('Foo [a.b.c] = d');
eq_(fn.callCount, 1);
}
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:properties.spec.ts
示例4: customTag_get
define FooFromTmpl {
h4 > 'FooFromTmpl'
}
`)
var compo = customTag_get('FooFromTmpl');
is_(compo, 'Function');
var dom = renderer_render('FooFromTmpl');
return UTest.domtest(dom, `
find('h4') > text FooFromTmpl;
`);
},
'let' () {
'> create owner component'
var Foo = Compo({});
customTag_define('Foo', Foo);
'> register from template in the owners scope'
customTag_registerFromTemplate(`
let LetBaz {
h4 > 'LetBaz'
}
`, Foo);
listeners_on('error', assert.await(error => has_(error.message, 'LetBaz')));
var dom = renderer_render(`
Foo {
LetBaz;
}
LetBaz;
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:register.spec.ts
示例5: UTest
import { customTag_define } from '@core/custom/tag';
import { Compo } from '@compo/exports';
import { jMask } from '@mask-j/jMask';
import { renderer_render } from '@core/renderer/exports';
import { parser_parse, mask_stringify } from '@core/parser/exports';
import { mask_config } from '@core/api/config';
UTest({
$before () {
customTag_define('JustAContainer', Compo({}));
},
'function source' () {
var template = `
function doSmth (foo, bar) {
return Service(foo);
};
`;
var node = jMask(template).filter('function').get(0);
deepEq_(node.args, [{prop:'foo'}, {prop:'bar'}]);
var clean = str => str.replace(/\s*/g, '');
eq_(clean(node.body), clean('return Service(foo);'))
},
'function node' () {
var dom = renderer_render(`
JustAContainer {
function doChange() {
this.$.text('B');
}
slot change () {
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:function.spec.ts
示例6: deepEq_
'should map tree': {
'should map nodes tree' () {
var ast = mask_TreeWalker.map(parser_parse('div > span'), node => {
return { tagName: node.tagName.toUpperCase() };
});
deepEq_(ast, {
tagName: 'DIV',
nodes: [
{ tagName: 'SPAN' }
]
});
},
'should map components tree' () {
customTag_define('Foo', Compo({
serialize () {
return 'iFoo'
},
}));
customTag_define('Bar', Compo({
serialize () {
return 'iBar'
}
}));
var root = Compo.initialize('Foo > Bar');
var foo = Compo.find(root, 'Foo');
var tree = mask_TreeWalker.map(foo, compo => {
return { text: compo.serialize() };
});
deepEq_(tree, {
text: 'iFoo',
components: [
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:TreeWalker.spec.ts
示例7: UTest
import { customTag_define } from '@core/custom/exports'
import { Compo } from '@compo/exports'
import '@core/feature/methods/exports'
import '@core/feature/modules/exports'
declare var sinon;
UTest({
'slot should be private (do not pass the signal to parent)' () {
var parentFn = sinon.spy();
customTag_define('FooParent', Compo({
slots: {
test: parentFn
}
}));
customTag_define(`
define Foo {
var called = false;
slot private test () {
this.scope.called = true;
}
button x-click=test;
}
`);
var compo = Compo.initialize('FooParent > Foo');
return UTest
.domtest(compo.$, `
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:define-methods.spec.ts
注:本文中的@compo/exports.Compo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论