From 0436ad4a64e0c63fe813d59f067015921b424513 Mon Sep 17 00:00:00 2001 From: Slapbox Date: Thu, 1 Nov 2018 21:26:46 -0400 Subject: [PATCH] Skip operations on child nodes if !node.nodes.size (#2365) * Skip operations on child nodes if !node.nodes.size Avoid running decoration and text decoration related functions on child nodes that don't exist. * Uses isLeafBlock * Restores the original order of statements --- packages/slate-react/src/components/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/slate-react/src/components/node.js b/packages/slate-react/src/components/node.js index d620253ee..2b5faa4a8 100644 --- a/packages/slate-react/src/components/node.js +++ b/packages/slate-react/src/components/node.js @@ -151,7 +151,7 @@ class Node extends React.Component { // If it's a block node with inline children, add the proper `dir` attribute // for text direction. - if (node.object == 'block' && node.nodes.first().object != 'block') { + if (node.isLeafBlock()) { const direction = node.getTextDirection() if (direction == 'rtl') attributes.dir = 'rtl' }