Bug #3152

firefox component failure with reinstanciated TinyMCE

Submitted:
2010-10-04 15:49:27 By: Anonymous
Open Priority: 3 Resolution: None Assigned to: None
User agent: Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10
Screen info: 1080x1920x24

Description of problem:

The following error appears in Firebug when a TinyMCE form is instanciated by a AJAX call on a field that as already been TinyMCEiffied and cleaned.

Steps to reproduce:
1. Create a AJAX form with a TinyMCE instance on a field with id "my-name"
2. Make sure the submit button for your ajax form looks like :
<input type="submit" name="save" onsubmit="if(typeof(tinyMCE) !== 'undefined') { tinyMCE.triggerSave(); unloadTinyMCE(); };" />

with the following unloadTinyMCE() function.

function unloadTinyMCE()
{
if(typeof(tinyMCE) !== 'undefined')
{
tinymce.each(tinyMCE.editors, function(e) {
if(typeof(e) !== 'undefined')
{
tinymce.remove(e);
}
});
}
}


3. save your form and remove the form content from your html page. This should work without problem
4. Load your form using ajax, and init the TinyMCE editor on the field "my-name" . This should work too.
5. Save your form : the following error appears in firebug :

Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMHTMLDocument.implementation]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)


See : http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=67348
See : http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=22977

This bug may have a few duplicate, but i'm creating a new bug since i've a fix for the component failure :

Replace this : from line 6328 to line 6351 :

// Nodes needs to be attached to something in WebKit/Opera
// Older builds of Opera crashes if you attach the node to an document created dynamically
// and since we can't feature detect a crash we need to sniff the acutal build number
// This fix will make DOM ranges and make Sizzle happy!
impl = n.ownerDocument.implementation;
if (impl.createHTMLDocument && (tinymce.isOpera && opera.buildNumber() >= 1767)) {
// Create an empty HTML document
doc = impl.createHTMLDocument("");

// Add the element or it's children if it's a body element to the new document
each(n.nodeName == 'BODY' ? n.childNodes : [n], function(node) {
doc.body.appendChild(doc.importNode(node, true));
});

// Grab first child or body element for serialization
if (n.nodeName != 'BODY')
n = doc.body.firstChild;
else
n = doc.body;

// set the new document in DOMUtils so createElement etc works
oldDoc = t.dom.doc;
t.dom.doc = doc;
}


By :

if(tinymce.isOpera && opera.buildNumber() >= 1767) {
impl = n.ownerDocument.implementation;
if (impl.createHTMLDocument) {
// Create an empty HTML document
doc = impl.createHTMLDocument("");

// Add the element or it's children if it's a body element to the new document
each(n.nodeName == 'BODY' ? n.childNodes : [n], function(node) {
doc.body.appendChild(doc.importNode(node, true));
});

// Grab first child or body element for serialization
if (n.nodeName != 'BODY')
n = doc.body.firstChild;
else
n = doc.body;

// set the new document in DOMUtils so createElement etc works
oldDoc = t.dom.doc;
t.dom.doc = doc;
}
}


The change is minor :

it puts "impl = n.ownerDocument.implementation;" that cause the firefox components failure in the "if(tinymce.isOpera && opera.buildNumber() >= 1767) {" test.
This fix the component failure in firefox.

Reported by: Pierre-Yves Landur?Id: 3080912

 

If you wish to follow or post a comment, you need to be registered and logged in.

Comments

User Image
  • 2012-10-25 15:22:18

as

Hello!

I can confirm that your solution works. Tested on Windows Firefox 16.0.1 with tinyMCE 3.5.6 inside jquery.colorbox.

Hope your bug fix will make it into an official version!

User Image
  • 2013-02-14 15:14:31

toddtomlinson

Is there any movement on getting this into core. I ran into this problem on a Drupal site using the WYSIWYG module and TinyMCE. The issue is identical to the original description in this ticket. A modal window driven by ajax with TinyMCE textarea - clicking Save threw an error:

NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMHTMLDocument.implementation]
[Break On This Error]

...,function(){l[s]=i;g--;n(s);o()})}});if(!g){a.each(d,function(s){s.func.call(s.s...

Implementing the fix listed in the original posting fixed the problem.

User Image
  • 2013-02-14 16:04:09

Elijah Lynn

Thanks Todd!

I am not sure of the TinyMCE process but... Do we need to submit an official patch for this to make it in? Does anyone know?

User Image
  • 2013-03-04 14:39:22

Elijah Lynn

Here is a pull request that fixes this issue. This won't really help anyone unless they can recompile TinyMCE though - https://github.com/tinymce/tinymce/pull/175

User Image
  • 2013-03-04 16:06:40

Elijah Lynn

The actual fix that Todd implemented above is this diff on 3.5.6 of the tiny_mce_src.js, then it was minified using http://javascriptcompressor.com/ and then the output of that replaces the contents of tiny_mce.js.

Since I cannot upload files here I am going to upload it to the issue on Drupal.org. http://drupal.org/node/1907756#comment-7133690

User Image
  • 2013-07-24 22:02:23

Luke_sf

This is still happening in Firefox 22, Tinymce 3.5.8.

User Image
  • 2014-05-28 22:52:00

solaris

This is still happening in Firefox 29, Tinymce 4.0.

User Image
  • 2014-06-25 09:37:02

commilfo

This is still happening in Firefox 30, Tinymce 4.1.