Prevent superfluous `<br>` in `<pre>`
authorAlexander Ebert <ebert@woltlab.com>
Thu, 22 Dec 2016 13:12:13 +0000 (14:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 22 Dec 2016 13:12:13 +0000 (14:12 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Code.js

index 84f6289fcb6644674e2417855dd46ff351d74fec..9fd764832b4251af3ebf30adf969a3342db55443 100644 (file)
@@ -53,6 +53,11 @@ define(['EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util', 'Ui/Di
                        
                        var pre = this._editor.selection.block();
                        if (pre && pre.nodeName === 'PRE') {
+                               if (pre.childElementCount === 1 && pre.children[0].nodeName === 'BR') {
+                                       // drop superfluous linebreak
+                                       pre.removeChild(pre.children[0]);
+                               }
+                               
                                this._setTitle(pre);
                                
                                pre.addEventListener(WCF_CLICK_EVENT, this._callbackEdit);