From da93937b1982e64baf76a9b44e7b187fb0c23c09 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Fri, 21 Sep 2018 09:56:20 -0700 Subject: [PATCH] fix benchmarks --- benchmark/slate-react/rendering/decoration.js | 4 +++- packages/slate/src/models/decoration.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/benchmark/slate-react/rendering/decoration.js b/benchmark/slate-react/rendering/decoration.js index a811d1e60..4d7a59ec3 100644 --- a/benchmark/slate-react/rendering/decoration.js +++ b/benchmark/slate-react/rendering/decoration.js @@ -42,7 +42,9 @@ const decorations = texts.flatMap((t, index) => { key: t.key, offset: 1, }, - marks: [{ type: 'underline' }], + mark: { + type: 'underline', + }, }, ] }) diff --git a/packages/slate/src/models/decoration.js b/packages/slate/src/models/decoration.js index 287908041..5d79e2345 100644 --- a/packages/slate/src/models/decoration.js +++ b/packages/slate/src/models/decoration.js @@ -106,6 +106,15 @@ class Decoration extends Record(DEFAULTS) { static fromJSON(object) { const { anchor, focus, mark } = object + + if (!mark) { + throw new Error( + `Decorations must be created with a \`mark\`, but you passed: ${JSON.stringify( + object + )}` + ) + } + const decoration = new Decoration({ anchor: Point.fromJSON(anchor || {}), focus: Point.fromJSON(focus || {}),