Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[fixed] added getClientRects mock to window.document.createRange
Browse files Browse the repository at this point in the history
…for `CodeMirror` in the `highlight` module
  • Loading branch information
thealjey committed Jan 21, 2017
1 parent b54893e commit 5669a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions interfaces/jsdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module 'jsdom' {
setEnd(): void;
setStart(): void;
getBoundingClientRect(): Object;
getClientRects(): Array<any>;
};
};
};
Expand Down
7 changes: 6 additions & 1 deletion src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5669a2e

Please sign in to comment.