From 154187f1bc405d15137076ebc01549f240c9563f Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 19 Dec 2017 06:25:18 +0300 Subject: [PATCH] use offsetWidth to decide if the button text is ellipsized --- js/dom.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/dom.js b/js/dom.js index 73933db9..7ef18fae 100644 --- a/js/dom.js +++ b/js/dom.js @@ -28,14 +28,15 @@ $$.remove = (selector, base = document) => { // display a full text tooltip on buttons with ellipsis overflow and no inherent title const addTooltipsToEllipsized = () => { for (const btn of document.getElementsByTagName('button')) { - if (btn.title && !btn.titleIsForEllipsis || - btn.clientWidth === btn.preresizeClientWidth) { + if (btn.title && !btn.titleIsForEllipsis) { continue; } - btn.preresizeClientWidth = btn.clientWidth; - const padding = btn.offsetWidth - btn.clientWidth; - const displayedWidth = btn.getBoundingClientRect().width - padding; - if (btn.scrollWidth > displayedWidth) { + const width = btn.offsetWidth; + if (!width || btn.preresizeClientWidth === width) { + continue; + } + btn.preresizeClientWidth = width; + if (btn.scrollWidth > width) { const text = btn.textContent; btn.title = text.includes('\u00AD') ? text.replace(/\u00AD/g, '') : text; btn.titleIsForEllipsis = true;