mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 20:51:20 +02:00
speed up schema matching
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user