1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-17 12:41:44 +02:00

Perhaps Faster stack (#1847)

* Faster stack

* Faster stack

* Use memoize; but use reduceRight still

* Use memoize; but use reduceRight still
This commit is contained in:
Jinxuan Zhu
2018-06-10 20:16:01 -04:00
committed by Ian Storm Taylor
parent b13affefd6
commit e04021f02e

View File

@@ -135,17 +135,13 @@ class Stack extends Record(DEFAULTS) {
render(property, props, ...args) {
const plugins = this.getPluginsWith(property)
.slice()
.reverse()
let { children = null } = props
for (const plugin of plugins) {
return plugins.reduceRight((children, plugin) => {
if (!plugin[property]) return children
const ret = plugin[property](props, ...args)
if (ret == null) continue
props.children = children = ret
}
return children
if (ret == null) return children
props.children = ret
return ret
}, props.children === undefined ? null : props.children)
}
}