UNPKG

enzyme-adapter-preact-pure

Version:

Enzyme adapter for Preact

46 lines (45 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChildren = exports.getComponent = exports.getDOMNode = exports.getLastRenderOutput = exports.getLastVNodeRenderedIntoContainer = void 0; /** * Return the last VNode that was rendered into a container using Preact's * `render` function. */ function getLastVNodeRenderedIntoContainer(container) { const preactContainer = container; return preactContainer.__k; } exports.getLastVNodeRenderedIntoContainer = getLastVNodeRenderedIntoContainer; /** * Return the VNode returned when `component` was last rendered. */ function getLastRenderOutput(component) { const preactComponent = component; return getChildren(preactComponent.__v); } exports.getLastRenderOutput = getLastRenderOutput; /** * 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. */ function getDOMNode(node) { return node.__e; } exports.getDOMNode = getDOMNode; /** * Return the `Component` instance associated with a rendered VNode. */ function getComponent(node) { return node.__c; } exports.getComponent = getComponent; /** * Return the child VNodes associated with a rendered VNode. */ function getChildren(node) { return node.__k; } exports.getChildren = getChildren;