Properly trimming title
authorAlexander Ebert <ebert@woltlab.com>
Mon, 11 May 2015 21:48:34 +0000 (23:48 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 11 May 2015 21:48:34 +0000 (23:48 +0200)
wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js

index 97d88bd895d91d7a9484e706827cd6d95dd3eb8b..1563f2bcf8a06c6d9afee620c9da4939152d2b40 100644 (file)
@@ -56,6 +56,8 @@ define(['jquery', 'UI/Alignment'], function($, UIAlignment) {
                                element.classList.remove('jsTooltip');
                                
                                var title = element.getAttribute('title');
+                               title = (typeof title === 'string') ? title.trim() : '';
+                               
                                if (title.length) {
                                        element.setAttribute('data-tooltip', title);
                                        element.removeAttribute('title');
@@ -75,7 +77,9 @@ define(['jquery', 'UI/Alignment'], function($, UIAlignment) {
                _mouseEnter: function(event) {
                        var element = event.currentTarget;
                        var title = element.getAttribute('title');
-                       if (typeof title === 'string' && title !== '') {
+                       title = (typeof title === 'string') ? title.trim() : '';
+                       
+                       if (title !== '') {
                                element.setAttribute('data-tooltip', title);
                                element.removeAttribute('title');
                        }