Opened 14 years ago

Closed 10 years ago

#6152 closed Bug (fixed)

enterMode = br produces error in Firefox 3.6.8

Reported by: libek Owned by: Tobiasz Cudnik
Priority: Normal Milestone:
Component: UI : Enter Key Version: 3.5.2
Keywords: Firefox Cc: hoch@…, gav@…

Description

This is a brand-new problem; I just downloaded a clean install of 3.3.2. (No, I haven't tried it in the beta.)

[ I understand that this setting is unrecommended, but I really NEED it for the project I'm working on; I can't force the whole project to use <p>'s, so there's just no point in generating them. ]

The error being generated in 3.3.2 only shows up when you set it to enterMode = CKEDITOR.ENTER_BR (and this is in the config.js file, FYI). No errors happen when it's set to ENTER_P or ENTER_DIV.

The error Firefox's Error Console gives me is:

Error: C.getFirst().hasAttribute is not a function Source File: [...]ckeditor/ckeditor.js Line: 86

Attachments (2)

6152.patch (621 bytes) - added by Tobiasz Cudnik 14 years ago.
6152_fix.patch (267 bytes) - added by dchill42 14 years ago.
Patch file for plugins/wysiwygarea/plugin.js v > 3.5

Download all attachments as: .zip

Change History (22)

comment:1 Changed 14 years ago by libek

Although, for the record, I would GLADLY switch to <p>'s if anyone could tell me how to make a custom tag a block element.

CKEDITOR.dtd.$empty.lj = 1; CKEDITOR.dtd.$empty.user = 1;

<--this worked just fine on the custom tags <lj> and <user>, making it so that the fakeobjects plugin was able to handle them as an empty element.

CKEDITOR.dtd.$block.cut = 1;

<--didn't work at all. It shows up when I force an iteration of the block elements, but it still can't contain <p>'s, and it needs to be able to contain <p>'s AND <table>'s AND <div>'s.

...Just toooossing that out there, in case anyone has a really quick easy suggestion for me, because I'd LOVE for <p>'s to be a viable option.

comment:2 Changed 14 years ago by Tobiasz Cudnik

Owner: set to Tobiasz Cudnik
Status: newassigned

Changed 14 years ago by Tobiasz Cudnik

Attachment: 6152.patch added

comment:3 Changed 14 years ago by Tobiasz Cudnik

Status: assignedreview

Error happens when there is only text node in the editor, which doesn't have getAttribute method.

comment:4 Changed 14 years ago by Tobiasz Cudnik

Milestone: CKEditor 3.4.1

comment:5 Changed 14 years ago by Sa'ar Zac Elias

I'm not able to figure out how to reproduce the problem. Can any of you attach some more exact steps to reproduce the bug?

comment:6 Changed 14 years ago by Sa'ar Zac Elias

Keywords: Pending added

Both Tobiasz and I can't reproduce this issue anymore.

comment:7 Changed 14 years ago by Frederico Caldeira Knabben

Status: reviewassigned

comment:8 Changed 14 years ago by Sa'ar Zac Elias

Keywords: Pending removed
Status: assignedpending

comment:9 Changed 14 years ago by Niko Viitala

There is again the same problem in the latest nightly build:

D.getFirst().hasAttribute is not a function

If I comment out the enter mode variable the problem disappears.

comment:10 Changed 14 years ago by Sa'ar Zac Elias

Can you provide exact steps how to reproduce the bug? A sample page maybe?

comment:11 Changed 14 years ago by Tobiasz Cudnik

Status: pendingconfirmed

This bug happens when Firebug is enabled, enterMode=BR and you follow those steps:

  • Type something in the editor
  • Select all (CTRL+A)
  • Start typing (no backspace)

It happens always for me and it's annoying during development.

comment:12 Changed 14 years ago by Tobiasz Cudnik

Keywords: Firefox added

comment:13 Changed 14 years ago by Garry Yao

Milestone: CKEditor 3.4.2
Status: confirmedpending

This will probably not in 3.4.2, are you sure it's not a DUP of #5253?

comment:14 Changed 14 years ago by Tobiasz Cudnik

Status: pendingconfirmed

It's not a DUP of #5253, as i'm using Firebug 1.7X.0a3. You aren't able to reproduce it?

comment:15 Changed 14 years ago by martin_42

Cc: hoch@… added

I fixed the issue by changing:

ckeditor/_source/plugins/wysiwygarea/plugin.js

<    if ( !bodyChildsNum || ( bodyChildsNum == 1&& body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) )
---
>    if ( !bodyChildsNum || !body.getFirst() || ( bodyChildsNum == 1 && body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) )

comment:16 Changed 14 years ago by Garry Yao

Any error thrown in "selectionchange" event should be concealed by try...catch and thus can be only reproduced by enable error tracking of Firebug.

comment:17 Changed 14 years ago by George Vilches

Cc: gav@… added

comment:18 Changed 14 years ago by dchill42

This bug continues to be an issue in 3.5.2. When enterMode is set to CKEDITOR.ENTER_BR, and the editor loads with content, the first node of which is text (as opposed to a tag like <p>), body.getFirst().hasAttribute() is undefined. This is because getFirst() returns the text node, which does not have a hasAttribute() method. The offending code is in the activateEditing() function of the wysiwygarea plugin.

The previously posted patch also has a logic flaw, at least in newer versions. It runs the code block, which is ostensibly meant to remove the bogus node inserted by firebug. In the scenario described above, this results in the removal of the first text node from the editor. Instead, the test should be

(bodyChildsNum == 1 && body.getFirst().hasAttribute && body.getFirst().hasAttribute('_moz_editor_bogus_node'))

such that the node isn't tested for the obviously absent attribute on a text node, nor is the text node inadvertently removed.

I will attach a new patch with this fix in the hope that it will get incorporated into the next release.

Last edited 14 years ago by dchill42 (previous) (diff)

Changed 14 years ago by dchill42

Attachment: 6152_fix.patch added

Patch file for plugins/wysiwygarea/plugin.js v > 3.5

comment:19 Changed 14 years ago by dchill42

Version: 3.3.23.5.2

comment:20 Changed 10 years ago by Jakub Ś

Resolution: fixed
Status: confirmedclosed

I can no longer reproduce this issue in latest Firefox and CKEditor (4.4.7 and 4.5 beta at the time of writing).

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy