1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 01:02:31 +01:00

speed up schema matching

This commit is contained in:
Ian Storm Taylor 2016-08-15 14:45:36 -07:00
parent d49b792e99
commit a045d475d3

View File

@ -149,7 +149,7 @@ class Schema extends new Record(DEFAULTS) {
*/
__getComponent(object) {
const match = this.rules.find(rule => rule.match(object) && rule.render)
const match = this.rules.find(rule => rule.render && rule.match(object))
if (!match) return
return match.render
}
@ -167,7 +167,7 @@ class Schema extends new Record(DEFAULTS) {
__getDecorators(object) {
return this.rules
.filter(rule => rule.match(object) && rule.decorate)
.filter(rule => rule.decorate && rule.match(object))
.map((rule) => {
return (text) => {
return rule.decorate(text, object)
@ -191,8 +191,8 @@ class Schema extends new Record(DEFAULTS) {
let value
const match = this.rules.find((rule) => {
if (!rule.match(object)) return
if (!rule.validate) return
if (!rule.match(object)) return
value = rule.validate(object)
return value