| 57 | | |
| 58 | | if ( selection && selection.anchorNode && selection.anchorNode.nodeType == 1 ) |
| 59 | | { |
| 60 | | if ( this.GetType() == 'Control' ) |
| 61 | | { |
| 62 | | // This one is good for all browsers, expect Safari Mac. |
| 63 | | selectedElement = selection.anchorNode.childNodes[ selection.anchorOffset ] ; |
| 64 | | |
| 65 | | // For Safari (Mac only), the anchor node for a control selection is |
| 66 | | // the control itself, which seams logic. FF and Opera use the parent |
| 67 | | // as the anchor node, pointing to the control with the offset. |
| 68 | | // As FF created the selection "standard", Safari would do better by |
| 69 | | // following their steps. |
| 70 | | if ( !selectedElement ) |
| 71 | | selectedElement = selection.anchorNode ; |
| 72 | | else if ( selectedElement.nodeType != 1 ) |
| 73 | | return null ; |
| 74 | | } |
| 75 | | } |
| 76 | | |
| 77 | | return selectedElement ; |
| | 55 | if ( !selection || selection.rangeCount < 1 ) |
| | 56 | return null ; |
| | 57 | |
| | 58 | var range = selection.getRangeAt( 0 ) ; |
| | 59 | if ( range.startContainer != range.endContainer || range.startContainer.nodeType != 1 || range.startOffset != range.endOffset - 1 ) |
| | 60 | return null ; |
| | 61 | |
| | 62 | var node = range.startContainer.childNodes[ range.startOffset ] ; |
| | 63 | if ( node.nodeType != 1 ) |
| | 64 | return null ; |
| | 65 | |
| | 66 | return node ; |