Opened 13 years ago

Closed 12 years ago

#1094 closed defect (fixed)

Editor: Javascript error when image in Editor2 widget is repeatedly clicked for IE

Reported by: bill.blume@… Owned by: liucougar
Priority: high Milestone: 0.9
Component: Dijit Version: 0.3
Keywords: Cc: bill.blume@…
Blocked By: Blocking:

Description

When one quickly and repeatedly clicks on an image in the rich text editor (the Editor2 widget), one gets a javascript error from IE. The error occurs in the following line in Editor2.updateToolbar:

    var selectedNode = (h.ie) ? this.document.selection.createRange().parentElement() :
        this.window.getSelection().anchorNode;

The above line fails because the range returned by createRange() does not have a parentElement method. This is because when an image is selected, the returned range is a ControlRange? object instead of a TextRange? object.

I was able to fix this in my own code by changing the above line to:

      var selectedNode = null;
      if (h.ie) {
        if (this.document.selection.type != "Control") {
          selectedNode = this.document.selection.createRange().parentElement();
        }
      } else {
        selectedNode = this.window.getSelection().anchorNode;
      }

This bug occurs in version 3.1 of the Dojo toolkit. It only occurs for IE. You can easily reproduce this on the Jotspot wiki by selecting an image in your editor pane, then repeatedly and quickly clicking on it until you get a javascript error. It usually fails after about six clicks or so. It will not fail if you click slowly on it.

Change History (6)

comment:1 Changed 13 years ago by bill

Owner: changed from anonymous to liucougar

comment:2 Changed 13 years ago by dylan

Milestone: 0.4

comment:3 Changed 13 years ago by liucougar

Cc: bill.blume@… added

could you try the latest svn version whether it has this issue?

comment:4 Changed 13 years ago by liucougar

Milestone: 0.40.5

comment:5 Changed 12 years ago by bill

Component: WidgetsDijit
Summary: Javascript error when image in Editor2 widget is repeatedly clicked for IEEditor: Javascript error when image in Editor2 widget is repeatedly clicked for IE

comment:6 Changed 12 years ago by liucougar

Resolution: fixed
Status: newclosed

this seems to be fixed in 0.9 rewrite, closing

Note: See TracTickets for help on using tickets.