mootools/mootools-core — Issue #2211: new Element forbidden for IE!!
Author: ibolmo
Created: 2012-01-19 07:30:52+00:00
State: open
Labels: bug, enhancement

(from [Lighthouse](https://mootools.lighthouseapp.com/projects/2706/tickets/409-new-element-forbidden-for-ie))

To have mootools compatible, when more documents are involved, they are severals catch in current master.

Explanation: if element is created by new Element, its .ownerDocument is top document. If such element is injected in to another document, IE will alert some ugly error.

Bugs and fixed:

``` javascript
iframe = new Element(iframe || 'iframe', props);
```

IFrame should have additional option: document, and iframe creating should be:

``` javascript
iframe = this.options.document.newElement(iframe || 'iframe', props);
```

element set html

``` javascript
var first = new Element('div');
```

should be:

``` javascript
var first = this.getDocument.newElement('div');
```

Swiff, RequestHTML, Tips and Assets - also should have option document

Slide:

``` javascript
this.wrapper = wrapper || new Element('div', {
```
should be:

``` javascript
this.wrapper = wrapper || this.element.getDocument().newElement('div', {
```

Sortables should also retrieve document from lists.

----

(from [comment](https://mootools.lighthouseapp.com/projects/2706/tickets/409-new-element-forbidden-for-ie#ticket-409-2))

Rule 1)
Where ever you use new Element, which will be injected in some existing element, then zou have to retrieve right document: iamPlaceholder.getDocument().newElement

Rule 2)
Where ever you have to create new Element, and you don't know, where is be placed, then you have to add to you class overidable option {document:document}