mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-23 08:50:59 +01:00
26 lines
452 B
JavaScript
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
|