1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 09:13:24 +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) { __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 if (!match) return
return match.render return match.render
} }
@ -167,7 +167,7 @@ class Schema extends new Record(DEFAULTS) {
__getDecorators(object) { __getDecorators(object) {
return this.rules return this.rules
.filter(rule => rule.match(object) && rule.decorate) .filter(rule => rule.decorate && rule.match(object))
.map((rule) => { .map((rule) => {
return (text) => { return (text) => {
return rule.decorate(text, object) return rule.decorate(text, object)
@ -191,8 +191,8 @@ class Schema extends new Record(DEFAULTS) {
let value let value
const match = this.rules.find((rule) => { const match = this.rules.find((rule) => {
if (!rule.match(object)) return
if (!rule.validate) return if (!rule.validate) return
if (!rule.match(object)) return
value = rule.validate(object) value = rule.validate(object)
return value return value