enzyme-adapter-preact-pure
Version:
Enzyme adapter for Preact
38 lines (37 loc) • 1.04 kB
JavaScript
/**
* Return the last VNode that was rendered into a container using Preact's
* `render` function.
*/
export function getLastVNodeRenderedIntoContainer(container) {
const preactContainer = container;
return preactContainer.__k;
}
/**
* Return the VNode returned when `component` was last rendered.
*/
export function getLastRenderOutput(component) {
const preactComponent = component;
return getChildren(preactComponent.__v);
}
/**
* Return the rendered DOM node associated with a rendered VNode.
*
* "Associated" here means either the DOM node directly output as a result of
* rendering the vnode (for DOM vnodes) or the first DOM node output by a
* child vnode for component vnodes.
*/
export function getDOMNode(node) {
return node.__e;
}
/**
* Return the `Component` instance associated with a rendered VNode.
*/
export function getComponent(node) {
return node.__c;
}
/**
* Return the child VNodes associated with a rendered VNode.
*/
export function getChildren(node) {
return node.__k;
}