mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +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:
committed by
Ian Storm Taylor
parent
b13affefd6
commit
e04021f02e
@@ -135,17 +135,13 @@ class Stack extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
render(property, props, ...args) {
|
render(property, props, ...args) {
|
||||||
const plugins = this.getPluginsWith(property)
|
const plugins = this.getPluginsWith(property)
|
||||||
.slice()
|
return plugins.reduceRight((children, plugin) => {
|
||||||
.reverse()
|
if (!plugin[property]) return children
|
||||||
let { children = null } = props
|
|
||||||
|
|
||||||
for (const plugin of plugins) {
|
|
||||||
const ret = plugin[property](props, ...args)
|
const ret = plugin[property](props, ...args)
|
||||||
if (ret == null) continue
|
if (ret == null) return children
|
||||||
props.children = children = ret
|
props.children = ret
|
||||||
}
|
return ret
|
||||||
|
}, props.children === undefined ? null : props.children)
|
||||||
return children
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user