本文整理汇总了TypeScript中inferno.render函数的典型用法代码示例。如果您正苦于以下问题:TypeScript render函数的具体用法?TypeScript render怎么用?TypeScript render使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: render
() => render(template('Hello', {}, ' and ', 'Zoo'), container)
示例2: it
it('should insert to the middle', () => {
render(template(generateNodes(['c', 'd', 'e'])), container);
render(template(generateNodes(['a', 'b', 'e'])), container);
expect(container.textContent).to.equal('abe');
expect(container.firstChild.childNodes.length).to.equal(3);
});
示例3: afterEach
afterEach(() => {
render(null, container);
container.innerHTML = '';
document.body.removeChild(container);
});
示例4: it
it('should render a basic component', () => {
let template = (Component, title) =>
createElement('div', null,
createElement(Component, {
title,
name: 'basic-render'
})
);
expect(() => {
render(template(null, 'abc'), container);
}).to.throw();
expect(() => {
render(template({}, 'abc'), container);
}).to.throw();
render(template(BasicComponent1, 'abc'), container);
expect(container.firstChild.firstChild.getAttribute('class')).to.equal('basic');
expect(container.firstChild.firstChild.firstChild.getAttribute('class')).to.equal('basic-render');
expect(container.firstChild.firstChild.tagName).to.equal('DIV');
expect(container.firstChild.firstChild.firstChild.tagName).to.equal('SPAN');
expect(container.firstChild.firstChild.firstChild.innerHTML).to.equal('The title is abc');
expect(() => {
render(template({}, 'abc'), container);
}).to.throw();
expect(() => render(template(BasicComponent1, {}), container)).to.throw;
render(template(BasicComponent1, []), container);
render(template(BasicComponent1, 'abcdef'), container);
expect(container.firstChild.firstChild.getAttribute('class')).to.equal('basic');
expect(container.firstChild.firstChild.firstChild.getAttribute('class')).to.equal('basic-render');
expect(container.firstChild.firstChild.tagName).to.equal('DIV');
expect(container.firstChild.firstChild.firstChild.tagName).to.equal('SPAN');
expect(container.firstChild.firstChild.firstChild.innerHTML).to.equal('The title is abcdef');
render(template(BasicComponent1, null), container);
expect(container.firstChild.firstChild.getAttribute('class')).to.equal('basic');
expect(container.firstChild.firstChild.firstChild.getAttribute('class')).to.equal('basic-render');
expect(container.firstChild.firstChild.tagName).to.equal('DIV');
expect(container.firstChild.firstChild.firstChild.tagName).to.equal('SPAN');
expect(container.firstChild.firstChild.firstChild.innerHTML).to.equal('The title is ');
render(template(BasicComponent1, undefined), container);
expect(container.firstChild.firstChild.getAttribute('class')).to.equal('basic');
expect(container.firstChild.firstChild.firstChild.getAttribute('class')).to.equal('basic-render');
expect(container.firstChild.firstChild.tagName).to.equal('DIV');
expect(container.firstChild.firstChild.firstChild.tagName).to.equal('SPAN');
expect(container.firstChild.firstChild.firstChild.innerHTML).to.equal('The title is ');
render(template(BasicComponent1, '1234'), container);
expect(container.firstChild.firstChild.getAttribute('class')).to.equal('basic');
expect(container.firstChild.firstChild.firstChild.getAttribute('class')).to.equal('basic-render');
expect(container.firstChild.firstChild.tagName).to.equal('DIV');
expect(container.firstChild.firstChild.firstChild.tagName).to.equal('SPAN');
expect(container.firstChild.firstChild.firstChild.innerHTML).to.equal('The title is 1234');
});
示例5: unmountComponentAtNode
function unmountComponentAtNode(
container: Element | SVGAElement | DocumentFragment
): boolean {
render(null, container);
return true;
}
示例6: it
it('Second render (update)', () => {
render(template(null), container); // change style to null
expect(container.firstChild.firstChild.getAttribute('style')).to.be.oneOf([null, '']);
});
示例7: afterEach
afterEach(() => {
render(null, container);
});