1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-23 08:50:59 +01:00
slate/lib/utils/find-dom-node.js
2016-07-21 10:07:25 -07:00

26 lines
452 B
JavaScript

/**
* Find the DOM node for a `node`.
*
* @param {Node} node
* @return {Element} el
*/
function findDOMNode(node) {
const el = window.document.querySelector(`[data-key="${node.key}"]`)
if (!el) {
throw new Error(`Unable to find a dom node for "${node.key}". This is
often because of forgetting to add \`props.attributes\` to a component
returned from \`renderNode\`.`)
}
return el
}
/**
* Export.
*/
export default findDOMNode