diff options
Diffstat (limited to 'ext/js/dom')
| -rw-r--r-- | ext/js/dom/document-util.js | 4 | ||||
| -rw-r--r-- | ext/js/dom/dom-text-scanner.js | 4 | ||||
| -rw-r--r-- | ext/js/dom/panel-element.js | 26 | ||||
| -rw-r--r-- | ext/js/dom/popup-menu.js | 4 | ||||
| -rw-r--r-- | ext/js/dom/scroll-element.js | 6 | ||||
| -rw-r--r-- | ext/js/dom/selector-observer.js | 2 | ||||
| -rw-r--r-- | ext/js/dom/text-source-generator.js | 6 | 
7 files changed, 25 insertions, 27 deletions
| diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index 1ec699e6..a98bfe86 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -18,7 +18,9 @@  /**   * This class contains utility functions related to the HTML document. + * TODO : This class should be made non-static   */ +// eslint-disable-next-line unicorn/no-static-only-class  export class DocumentUtil {      /** @type {?boolean} */      static _cssZoomSupported = null; @@ -460,7 +462,7 @@ export class DocumentUtil {              if (typeof value !== 'string' || value.length === 0) {                  return null;              } -            value = parseFloat(value); +            value = Number.parseFloat(value);          }          return !Number.isNaN(value) ? value : null;      } diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js index f1dc3661..5b3ea564 100644 --- a/ext/js/dom/dom-text-scanner.js +++ b/ext/js/dom/dom-text-scanner.js @@ -488,8 +488,8 @@ export class DOMTextScanner {      static isStyleVisible(style) {          return !(              style.visibility === 'hidden' || -            parseFloat(style.opacity) <= 0 || -            parseFloat(style.fontSize) <= 0 || +            Number.parseFloat(style.opacity) <= 0 || +            Number.parseFloat(style.fontSize) <= 0 ||              (                  !DOMTextScanner.isStyleSelectable(style) &&                  ( diff --git a/ext/js/dom/panel-element.js b/ext/js/dom/panel-element.js index 9c1289d7..0f2801e6 100644 --- a/ext/js/dom/panel-element.js +++ b/ext/js/dom/panel-element.js @@ -89,16 +89,14 @@ export class PanelElement extends EventDispatcher {       * @param {(details: import('core').EventArgument<import('panel-element').Events, TName>) => void} callback       */      on(eventName, callback) { -        if (eventName === 'visibilityChanged') { -            if (this._mutationObserver === null) { -                this._visible = this.isVisible(); -                this._mutationObserver = new MutationObserver(this._onMutation.bind(this)); -                this._mutationObserver.observe(this._node, { -                    attributes: true, -                    attributeFilter: ['hidden'], -                    attributeOldValue: true -                }); -            } +        if (eventName === 'visibilityChanged' && this._mutationObserver === null) { +            this._visible = this.isVisible(); +            this._mutationObserver = new MutationObserver(this._onMutation.bind(this)); +            this._mutationObserver.observe(this._node, { +                attributes: true, +                attributeFilter: ['hidden'], +                attributeOldValue: true +            });          }          super.on(eventName, callback);      } @@ -111,11 +109,9 @@ export class PanelElement extends EventDispatcher {       */      off(eventName, callback) {          const result = super.off(eventName, callback); -        if (eventName === 'visibilityChanged' && !this.hasListeners(eventName)) { -            if (this._mutationObserver !== null) { -                this._mutationObserver.disconnect(); -                this._mutationObserver = null; -            } +        if (eventName === 'visibilityChanged' && !this.hasListeners(eventName) && this._mutationObserver !== null) { +            this._mutationObserver.disconnect(); +            this._mutationObserver = null;          }          return result;      } diff --git a/ext/js/dom/popup-menu.js b/ext/js/dom/popup-menu.js index 8a8a19ba..28bcc309 100644 --- a/ext/js/dom/popup-menu.js +++ b/ext/js/dom/popup-menu.js @@ -219,8 +219,8 @@ export class PopupMenu extends EventDispatcher {              (bottom - top) * ((-vertical + 1) * -0.5)          ); -        x = Math.max(0.0, Math.min(containerNodeRect.width - menuRect.width, x)); -        y = Math.max(0.0, Math.min(containerNodeRect.height - menuRect.height, y)); +        x = Math.max(0, Math.min(containerNodeRect.width - menuRect.width, x)); +        y = Math.max(0, Math.min(containerNodeRect.height - menuRect.height, y));          menu.style.left = `${x}px`;          menu.style.top = `${y}px`; diff --git a/ext/js/dom/scroll-element.js b/ext/js/dom/scroll-element.js index 8005469b..7cd00f01 100644 --- a/ext/js/dom/scroll-element.js +++ b/ext/js/dom/scroll-element.js @@ -133,10 +133,10 @@ export class ScrollElement {       */      _easeInOutCubic(t) {          if (t < 0.5) { -            return (4.0 * t * t * t); +            return (4 * t * t * t);          } else { -            t = 1.0 - t; -            return 1.0 - (4.0 * t * t * t); +            t = 1 - t; +            return 1 - (4 * t * t * t);          }      } diff --git a/ext/js/dom/selector-observer.js b/ext/js/dom/selector-observer.js index 791ce627..86607130 100644 --- a/ext/js/dom/selector-observer.js +++ b/ext/js/dom/selector-observer.js @@ -170,7 +170,7 @@ export class SelectorObserver {          if (              this._onChildrenUpdated !== null && -            (addedNodes.length !== 0 || addedNodes.length !== 0) +            (removedNodes.length > 0 || addedNodes.length > 0)          ) {              for (let node = /** @type {?Node} */ (target); node !== null; node = node.parentNode) {                  const observer = this._elementMap.get(node); diff --git a/ext/js/dom/text-source-generator.js b/ext/js/dom/text-source-generator.js index a5529779..83c7271c 100644 --- a/ext/js/dom/text-source-generator.js +++ b/ext/js/dom/text-source-generator.js @@ -307,8 +307,8 @@ export class TextSourceGenerator {          // Adjust size          const imposterRect = imposter.getBoundingClientRect();          if (imposterRect.width !== elementRect.width || imposterRect.height !== elementRect.height) { -            const width = parseFloat(elementStyle.width) + (elementRect.width - imposterRect.width); -            const height = parseFloat(elementStyle.height) + (elementRect.height - imposterRect.height); +            const width = Number.parseFloat(elementStyle.width) + (elementRect.width - imposterRect.width); +            const height = Number.parseFloat(elementStyle.height) + (elementRect.height - imposterRect.height);              this._setImposterStyle(imposterStyle, 'width', `${width}px`);              this._setImposterStyle(imposterStyle, 'height', `${height}px`);          } @@ -614,7 +614,7 @@ export class TextSourceGenerator {          }          const style = window.getComputedStyle(element);          return ( -            parseFloat(style.opacity) <= 0 || +            Number.parseFloat(style.opacity) <= 0 ||              style.visibility === 'hidden' ||              (style.backgroundImage === 'none' && this._isColorTransparent(style.backgroundColor))          ); |