当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Compo.initialize方法代码示例

本文整理汇总了TypeScript中@compo/exports.Compo.initialize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Compo.initialize方法的具体用法?TypeScript Compo.initialize怎么用?TypeScript Compo.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@compo/exports.Compo的用法示例。


在下文中一共展示了Compo.initialize方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: onRenderStart

		'should call onRenderStart' () {
			var template = `
				define foo {
					function onRenderStart(model) {
						eq_(model.name, 'Foo');
						this.parent.count = this.parent.count == null
							? 1
							: ++this.parent.count
							;
					}
				}
				foo;
				foo;
			`;
			
			var app = Compo.initialize(template, { name: 'Foo' });
			var Foo = customTag_get('foo');
			is_(Foo.prototype.onRenderStart, 'Function');
			
			eq_(app.components.length, 3);
			eq_(app.count, 2);
		},
		'should define a function' () {
			var template = `
				define foo {
					function fooBar() {
						return 'hello';
					}
					h4 > 'Foo'
				}
				foo;
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:define.spec.ts


注:本文中的@compo/exports.Compo.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。