1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

add helpful error to findDOMNode util, closes #147

This commit is contained in:
Ian Storm Taylor
2016-07-21 10:07:25 -07:00
parent 30a2abb87d
commit 1a3ef3854b

View File

@@ -7,7 +7,15 @@
*/
function findDOMNode(node) {
return window.document.querySelector(`[data-key="${node.key}"]`)
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
}
/**