alohaeditor/Aloha-Editor — Issue #413: On Paste: Cannot read property 'document' of null
Author: NeilFraser
Created: 2012-01-27 09:08:07+00:00
State: open

1. Open the editor at http://aloha-editor.org/ using Chrome.
2. In another tab, open the Acid 3 Test at http://acid3.acidtests.org/
3. Select-all on the Acid 3 test, copy, and paste into the editor.

Expected: Some content should be pasted.
Actual: Uncaught TypeError: Cannot read property 'document' of null. aloha.js:7353

The debugger shows me that elem is an HTMLIFrameElement with a contentDocument of undefined and a contentWindow of null.

Suggest changing this line:
return jQuery.nodeName( elem, "iframe" ) ?
elem.contentDocument || elem.contentWindow.document :
jQuery.makeArray( elem.childNodes );
to this:
return jQuery.nodeName( elem, "iframe" ) ?
elem.contentDocument || (elem.contentWindow && elem.contentWindow.document) :
jQuery.makeArray( elem.childNodes );