[BUGFIX] RTE may overwrite link text in IE
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 9 Sep 2011 03:34:28 +0000 (23:34 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 12 Sep 2011 22:42:22 +0000 (00:42 +0200)
Problem: In IE, setting the link node href attribute may update the link
content when the content is recognized by IE as an url.
Solution: Workaround the IE feature and restore the link content.

Change-Id: I6f41dd2e43a64726e48dc3c714c7cfe89bbc860a
Resolves: #29527, #25464
Releases: 4.5, 4.6
Reviewed-on: http://review.typo3.org/4863
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js

index 68d75db..a4e4043 100644 (file)
@@ -206,36 +206,35 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
                                }
                        }
                }
-               if (!Ext.isIE && node != null && /^a$/i.test(node.nodeName)) {
-                               // Update existing link in non-IE
+               if (node != null && /^a$/i.test(node.nodeName)) {
+                               // Update existing link
                        this.editor.selectNode(node);
                        selection = this.editor._getSelection();
                        range = this.editor._createRange(selection);
-                               // Clean images
+                               // Clean images, keep links
                        if (HTMLArea.classesAnchorSetup) {
                                this.cleanAllLinks(node, range, true);
                        }
                                // Update link href
+                               // In IE, setting href may update the content of the element. We don't want this feature.
+                       if (Ext.isIE) {
+                               var content = node.innerHTML;
+                       }
                        node.href = Ext.isGecko ? encodeURI(theLink) : theLink;
+                       if (Ext.isIE) {
+                               node.innerHTML = content;
+                       }
                                // Update link attributes
                        this.setLinkAttributes(node, range, cur_target, cur_class, cur_title, imageNode, addIconAfterLink, additionalValues);
                } else {
                                // Create new link
-                               // Update links in IE
                        selection = this.editor._getSelection();
                        range = this.editor._createRange(selection);
-                       if (Ext.isIE) {
-                                       // Clean images, keep links
-                               if (HTMLArea.classesAnchorSetup) {
-                                       this.cleanAllLinks(node, range, true);
-                               }
-                       } else {
-                                       // Clean existing anchors otherwise Mozilla may create nested anchors
-                                       // Selection may be lost when cleaning links
-                               var bookmark = this.editor.getBookmark(range);
-                               this.cleanAllLinks(node, range);
-                               this.editor.selectRange(this.editor.moveToBookmark(bookmark));
-                       }
+                               // Clean existing anchors otherwise Mozilla may create nested anchors while IE may update exisitng link
+                               // Selection may be lost when cleaning links
+                       var bookmark = this.editor.getBookmark(range);
+                       this.cleanAllLinks(node, range);
+                       this.editor.selectRange(this.editor.moveToBookmark(bookmark));
                        if (Ext.isGecko) {
                                this.editor.document.execCommand('CreateLink', false, encodeURI(theLink));
                        } else {