When trying to edit a page in IE8 that contains teaser break, I get the following JavaScript error:

Melding: Ugyldig peker. (=Invalid pointer?)
Linje: 51
Tegn: 5
Kode: 0
URI: http://../dp6/sites/all/modules/wysiwyg/plugins/break/break.js?U

The rich text editor loads, with text and images, but does not show the teaser break line. When disabling rich text I see the

tag.
Whatever editing I try to do does not happen, even if Dupal confirmes that text is updated after saving the page.

Tried editing in "compatibility view" in IE8, and it works OK.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TwoD’s picture

I'm assigning this to me. Once again, this has something to do with inserting comments. What fixed it for IE6 and IE7 wasn't enough for IE8 I guesś...
See #404532: TinyMCE/FCKeditor: Teaser break vanishes in IE6/7 for reference. I'll not mark this as duplicate since the consequences are much more severe here because an exception is actually triggered.
And there's a slight chance that it's not exactly the same bug, but still related.

TwoD’s picture

Assigned: Unassigned » TwoD

Of course I forgot to actually do it...

sun’s picture

Title: Java Script error in IE8 when teaser break is present » Teaser Break: IE8: JavaScript error
Component: Editor - TinyMCE » Plugins

I wonder whether jQuery might handle this correctly already? I.e.

     // document.createComment() required or IE will strip the comment.
-    $('img.wysiwyg-break', $content).replaceWith(document.createComment('break'));
+    $('img.wysiwyg-break', $content).replaceWith($('<!--break-->'));

At least, it feels a bit strange that we need to "invent" all of this...

Hm... Additionally, there is a conflict in this bug report with the actual error message. That code (line 51) belongs to

   * Replace images with <!--break--> tags in content upon detaching editor.

but the original post states that the detaching works, but not the attaching...?

TwoD’s picture

Line 46 in break.js is * Replace images with <!--break--> tags in content upon detaching editor.
Line 51 in break.js is $('img.wysiwyg-break', $content).replaceWith(document.createComment('break'));.

I believe that what jofje meant was that the attaching works (as he can edit content, but changes do not stick) but after inserting a Teaser Break, or if one is already present, that error pops up when he disables rich text editing or submits the page, which is when detachment occurs. At least those where the symptoms I saw in IE8 and the debugger.

I've tested $('img.wysiwyg-break', $content).replaceWith($('<!--break-->')); in IE6 and it just removes the comment...
document.createComment('break') should be the correct way to do this, but for some reason IE8 doesn't play nice.
I've read about some issues where elements created the main document in IE8 and then inserted into an iframe will break things because they don't have the same owner document.
I'm unsure if this is related to that though.

I'll be able to continue debugging this in about an hour when I get my netbook back.

jofje’s picture

Think TwoD got my message mostly right (English is not my native language, and your disussion about attaching/detaching is a little bit over my technical knowledge).

Anyway to clarify(?) a little:
I use latest dev versions of Image, Image Assist, Wysiwyg and Inline, and with TinyMCE 3.2.4.1.
I have rich text enabled by default.

In IE8 opening and editing of pages without teaser break: All OK

Opening page with previously inserted teaser break (with another browser of course, see below) for editing: No visible teaser break, and a yellow exclamation mark down left (double-clicking that one shows me the before mentioned JS-error; confirmes line 51). Whatever editing I do does not stick.

But, if I disable the rich text editor, I can se the

tag, and editing done while in simple text mode *does* stick, as long as I don't switch back to rich text before saving.

Trying to add new content from scratch using IE8: All OK as long as I don't add teaser break. If I try to add a teaser break to the text, and saves, the result is a new page with zero content - no text, no teaser break, nothing.

TwoD’s picture

Ah, yes. The plugins are detached once upon attaching the editor (triggered internally by FCKeditor), which is why the error appears when jofje opens the page and there's already a teaser break in there.

The changes won't stick because the plugin detach code is called (and fails) during editor detachment which was initiated onSubmit. Because the plugin code fails, FCKeditor doesn't complete its onSubmit routine and the textarea isn't updated with the changed contents.

I have found a solution to the above problem: do not use jQuery to insert the comment, use the appropriate DOM methods instead.

I'm having problems tracing the exact source of the problem within the guts of jQuery. As soon as I try to insert the comment using jQuery it breaks in the clean method. When comparing the constructor of the inserted element to Number it says that .constructor is an invalid pointer. Why I don't know, but I can't seem to avoid it by other means than simplifying the operation down to not using jQuery for the actual element insertion. Since the operation is pretty straight forward and not likely to fail, I foresee no problems with this.

Tested in IE6/8 and FF3.

TwoD’s picture

Some cleanups and clarifications, once again thanks to Sun. =)

TwoD’s picture

Oops, wrong file. I'm not having much luck with this upload form, and probably shouldn't write code this late...

TwoD’s picture

Some more changes, finally done.

TwoD’s picture

Status: Active » Fixed

Committed, with the addition of a few semicolons which kept eluding me. =)

sun’s picture

@TwoD: For 2.x, you also need a checkout of DRUPAL-5--2 ;)

Also committed to 5.x-2.x.

TwoD’s picture

Oh, right, thanks!

jofje’s picture

Looks promising (even if I don't have a clue about what you are talking about, JQuery and all that). Don't have time to test right now, but will report back tomorrow at the latest.

Guess it doesn't matter that TwoD talkes about FCKeditor in #6 (I have never used it, just TinyMCE)?

TwoD’s picture

I was using FCKeditor at the time of writing #6, but of course this applies to any editor supporting Drupal plugins like Teaser Break, as they would all run that code.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.