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

Deprecating using setNode to update nodes

This commit is contained in:
Soreine
2016-10-26 15:59:06 +02:00
parent 6c43cd57e1
commit 97aa3ecd93

View File

@@ -1,5 +1,6 @@
import Debug from 'debug' import Debug from 'debug'
import warning from '../utils/warning'
/** /**
* Debug. * Debug.
@@ -294,6 +295,12 @@ function setNode(state, operation) {
const { path, properties } = operation const { path, properties } = operation
let { document } = state let { document } = state
let node = document.assertPath(path) let node = document.assertPath(path)
// Deprecate using setNode for updating children
if (properties.nodes && properties.nodes != node.nodes) {
warning('Updating Node.nodes through setNode is deprecated. Use the appropriate insertion and removal functions, rather than, for example, setNodeByKey.')
}
node = node.merge(properties) node = node.merge(properties)
document = document.updateDescendant(node) document = document.updateDescendant(node)
state = state.merge({ document }) state = state.merge({ document })