marijnh/CodeMirror2 — Issue #215: Unknown runtime error in IE7/8/9
Author: claviska
Created: 2011-10-23 23:35:23+00:00
State: open

IE displays this error when you try to insert a block-level element into an element that doesn't support them via innerHTML. I traced the problem I was having down to line 1215 in codemirror.js:

```javascript
measure.innerHTML = "

x

";
```

The problem is that, if you have your textarea inside of a paragraph element (like many do), you get this 'Unknown runtime error' when initializing CodeMirror.fromTextArea() and the editor fails to load. The workaround is to change the paragraph to an element that supports block-level children—a DIV for example.

I'm not sure how to approach a fix for this. Having a textarea inside of a paragraph element is perfectly valid, so letting CodeMirror error-out without any warning doesn't seem like a good idea. It took me a bit to figure out why it wasn't working in IE, whereas a try/catch or even a smarter check would have saved me a lot of time.

Here's some sample markup to reproduce the issue in IE:

```html

Source:

```

```javascript
var editor = CodeMirror.fromTextArea( document.getElementById('source') );
```