本文整理汇总了TypeScript中@compo/exports.Compo类的典型用法代码示例。如果您正苦于以下问题:TypeScript Compo类的具体用法?TypeScript Compo怎么用?TypeScript Compo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Compo类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: customTag_define
customTag_define(template).done(() => {
var Foo = Compo.initialize('Foo');
deepEq_(Foo.getJsExports_Prop(), { name: 'Foo'});
deepEq_(Foo.getJsExports_PropAlias(), { name: 'Foo'});
eq_(Foo.getTextImport(), 'Hello foo baz!');
eq_(Foo.getTextAlikeImport(), 'name=Baz');
done();
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:8,代码来源:methods-define.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: mask_config
`);
mask_config('getFile', null);
deepEq_(_queue, ['MyComponents.mask', 'MyLetter.mask']);
await UTest.domtest(dom, `
find ('h1') > text ('B');
`);
},
'should load async javascripts scope' (done) {
customTag_define('TestAsync', Compo.create({
onRenderStart () {
var x = this.$scope('X');
eq_(x, null, 'Scope should be empty, while still loading');
setTimeout(() => {
x = this.$scope('X');
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');
开发者ID:atmajs,项目名称:MaskJS,代码行数:32,代码来源:async.spec.ts
示例4: UTest
import { Compo } from '@compo/exports';
UTest({
'should include template without defining a component' () {
var template = `
define TestInclude {
div > @foo;
}
include TestInclude {
@foo > span;
}
`;
var compo = Compo.initialize(template);
eq_(compo.components.length, 1);
eq_(compo.components[0].compoName, 'define');
compo
.$
.has_('div > span');
}
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:23,代码来源:include.spec.ts
示例5: Foo
h5 > '~[.]'
}
Foo (me, me.name.toUpperCase())
`;
var dom = renderer_render(template, { me: { name: 'ifoo' }});
return UTest.domtest(dom, `
find (h5) > text rewritten;
`);
}
},
'should created binded function' () {
var template = `
let Foo {
function self test () {
this.testy = 'Lorem';
}
div;
}
Foo;
`;
var root = Compo.initialize(template);
var foo = root.find('Foo');
is_(foo.test, 'Function');
var fn = foo.test;
fn.call(null);
eq_(foo.testy, 'Lorem');
}
});
开发者ID:atmajs,项目名称:MaskJS,代码行数:29,代码来源:define.spec.ts
示例6: Compo
'Scoped Template' () {
var Foo = Compo({
template: '2_Y_Define; 2_Y_Let;'
});
customTag_define('RTFoo', Foo);
customTag_define('RTFoo', `
define 2_Y_Define {}
let 2_Y_Let {}
`);
'> get from global'
var x = customTag_get('2_Y_Define');
is_(x, 'Function');
eq_(x.name, 'CompoBase');
'> should be scoped'
var x = customTag_get('2_Y_Let');
eq_(x, null);
'> get from scope'
var x = customTag_get('2_Y_Let', Foo);
is_(x, 'Function');
eq_(x.name, 'CompoBase');
'> render with the children'
var foo = Compo.initialize(Foo);
is_(foo.find('2_Y_Let'), 'Object');
}
}
})
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:register.spec.ts
示例7: Foo
$(dom)
.filter('h4')
.eq_('length', 1)
.eq_('text', 'HELLO');
},
'... for arguments' () {
var template = `
define Foo (user) {
function testFn () {
return user.name;
}
}
`;
customTag_define(template);
var Wrapper = Compo.initialize('Foo (bob)', { bob: { name: 'IBob'}});
var Foo = Wrapper.find('Foo');
eq_(Foo.testFn(), 'IBob');
},
'// (should be implemented: binding and setter problem)... for variables' () {
var template = `
define Foo {
var WIDTH = 10 / 2;
function onRenderStart () {
this.width = WIDTH;
}
}
`;
var Foo = Compo.initialize('Foo');
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:methods-define.spec.ts
示例8: customTag_define
{ 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: [
{ text: 'iBar' }
]
});
}
},
'should superpose trees': {
'should copy id attributes from one tree to another' () {
var treeA = parser_parse('div > span');
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:TreeWalker.spec.ts
示例9: customTag_define
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.$, `
find(button) > click;
`)
.then(() => {
var foo = compo.find('Foo');
eq_(foo.scope.called, true);
eq_(parentFn.callCount, 0);
});
}
})
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:define-methods.spec.ts
注:本文中的@compo/exports.Compo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论