From 5669a2e2956f2f8f1f8e886523c65fa7edd62619 Mon Sep 17 00:00:00 2001 From: Eugene Kuzmenko Date: Sat, 21 Jan 2017 09:11:04 +0100 Subject: [PATCH] [fixed] added `getClientRects` mock to `window.document.createRange` for `CodeMirror` in the `highlight` module --- interfaces/jsdom.js | 1 + src/highlight.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/interfaces/jsdom.js b/interfaces/jsdom.js index a3a14ed..b595ea0 100644 --- a/interfaces/jsdom.js +++ b/interfaces/jsdom.js @@ -9,6 +9,7 @@ declare module 'jsdom' { setEnd(): void; setStart(): void; getBoundingClientRect(): Object; + getClientRects(): Array; }; }; }; diff --git a/src/highlight.js b/src/highlight.js index 68e691e..f77c5e2 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -16,7 +16,12 @@ import {transformElements, arrayToJSX} from './jsx'; if ('undefined' === typeof navigator) { global.window = jsdom().defaultView; global.navigator = window.navigator; - window.document.createRange = constant({setEnd: noop, setStart: noop, getBoundingClientRect: constant({})}); + window.document.createRange = constant({ + setEnd: noop, + setStart: noop, + getBoundingClientRect: constant({}), + getClientRects: constant([]) + }); global.document = window.document; }