sleemanj / xinha

WYSIWYG HTML Editor Component (turns <textarea> into HTML editors)
http://trac.xinha.org/
Other
13 stars 2 forks source link

IE BUG in _getFirstAncestor() when selection empty (Trac #1510) #1510

Closed sleemanj closed 3 years ago

sleemanj commented 14 years ago

This is IE only. Let's say you have code like this.

var selection  = this.editor.getSelection();
this.editor._getFirstAncestor(selection,['span']);  

If the selection is empty, I mean you just clicked into the document, _getFirstAncestor() will return null on IE8. Even though it is surrounded by . Firefox behaves right and returns the ancestor node.

getSelection() seems to be ok as it returns a selection object even in IE.

Reported by guest, migrated from http://trac.xinha.org/ticket/1510

sleemanj commented 14 years ago

I '''strongly''' suspect this will be related to ticket:1508 owing to the fact that _getFirstAncestor also uses createRange, which does that focus when a None selection (just an insertion point) is presented to it.

That would focus the editor as a whole and probably produce this null return.

Microsoft made definite changes to IE8's focus model,

''Internet Explorer 8 and later. When a Web page is displayed in IE8 mode, an object cannot receive focus when sCanEdit is set to false. When pages are displayed in earlier document compatibility modes, objects can receive focus when sCanEdit is false.''

http://msdn.microsoft.com/en-us/library/ms533690(VS.85).aspx

sleemanj commented 14 years ago

@sleemanj commented:

See #1508, #1471