Skip to content

Commit 80ea07c

Browse files
committed
Work around IE getBoundingClientRect bug
In some modes, when querying a visibility: hidden node inside of an iframe, IE8 and 9 will return nonsense coordinates.
1 parent 6a51c47 commit 80ea07c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/codemirror.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ var CodeMirror = (function() {
756756
function scrollEditorIntoView() {
757757
if (!cursor.getBoundingClientRect) return;
758758
var rect = cursor.getBoundingClientRect();
759+
// IE returns bogus coordinates when the instance sits inside of an iframe and the cursor is hidden
760+
if (ie && rect.top == rect.bottom) return;
759761
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
760762
if (rect.top < 0 || rect.bottom > winH) cursor.scrollIntoView();
761763
}

0 commit comments

Comments
 (0)