Opened 14 years ago

Closed 14 years ago

#440 closed defect (fixed)

getParentElement returns wrong parent in IE

Reported by: Artus Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

There seems to be a bug in IE, which causes getParentElement to return a wrong parent in certain situations. For instance in the list in your example, when you select:

  • [from here] Phasellus et massa sed diam viverra semper.
  • Mauris tincidunt felis in odio. [to here]

Then you get an li element as parent and not the ul element.

These changes in getParentElement should circumvent the problem:

...
  if (HTMLArea.is_ie) {
    switch (sel.type) {
        case "Text":
      // try to circumvent a bug in IE:
      // the parent returned is not always the real parent element    
      var parent = range.parentElement();
      while (true)
      {
        var TestRange = range.duplicate();
        TestRange.moveToElementText(parent);
        if (TestRange.inRange(range)) break;
        if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) break;
        parent = parent.parentElement;
      };
      return parent;
        case "None":
      // It seems that even for selection of type "None",
      // there _is_ a parent element and it's value is not
      // only correct, but very important to us.  MSIE is
      // certainly the buggiest browser in the world and I
      // wonder, God, how can Earth stand it?
      return range.parentElement();
        case "Control":
      return range.item(0);
        default:
      return this._doc.body;
    }
...

Change History (1)

comment:1 Changed 14 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

Applied changeset:397

Note: See TracTickets for help on using tickets.