本文整理匯總了TypeScript中@phosphor/virtualdom.VirtualDOM類的典型用法代碼示例。如果您正苦於以下問題:TypeScript VirtualDOM類的具體用法?TypeScript VirtualDOM怎麽用?TypeScript VirtualDOM使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了VirtualDOM類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should clear the rendering if `null` content is provided', () => {
let host = document.createElement('div');
VirtualDOM.render(h('div', ['bar', 'foo']), host);
expect(host.children[0].childNodes.length).to.equal(2);
VirtualDOM.render(null, host);
expect(host.children.length).to.equal(0);
});
示例2: it
it('should connect a node to a command', () => {
let called = false;
const command = 'commandlinker:connect-node';
const commands = new CommandRegistry();
const linker = new CommandLinker({ commands });
let node: HTMLElement;
let vnode: VirtualNode;
const disposable = commands.addCommand(command, {
execute: () => {
called = true;
}
});
vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
node = VirtualDOM.realize(vnode);
document.body.appendChild(node);
expect(called).to.equal(false);
simulate(node, 'click');
expect(called).to.equal(true);
document.body.removeChild(node);
linker.dispose();
disposable.dispose();
});
示例3: createButtonNode
/**
* Create a button node for the dialog.
*
* @param button - The button data.
*
* @returns A node for the button.
*/
createButtonNode(button: IButton): HTMLElement {
let className = this.createItemClass(button);
// We use realize here instead of creating
// nodes with document.createElement as a
// shorthand, and only because this is not
// called often.
return VirtualDOM.realize(
h.button({ className },
this.renderIcon(button),
this.renderLabel(button))
);
}
示例4: createHeader
/**
* Create the header of the dialog.
*
* @param title - The title of the dialog.
*
* @returns A widget for the dialog header.
*/
createHeader(title: HeaderType): Widget {
let header: Widget;
if (typeof title === 'string') {
header = new Widget({ node: document.createElement('span') });
header.node.textContent = title;
} else {
header = new Widget({ node: VirtualDOM.realize(title) });
}
header.addClass('jp-Dialog-header');
Styling.styleNode(header.node);
return header;
}