本文整理匯總了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);
});