diff options
author | Darius Jahandarie <djahandarie@gmail.com> | 2023-11-04 18:45:57 +0900 |
---|---|---|
committer | Darius Jahandarie <djahandarie@gmail.com> | 2023-11-04 18:45:57 +0900 |
commit | ef79eab44bfd000792c610b968b5ceefd41e76a0 (patch) | |
tree | 48b04f30f6248caedbd880801aa49402a9e8066a /ext/js/dom | |
parent | 376151096431d4362e4baaacf0cef4a534e169f7 (diff) |
Modernize codebase
- Use ES modules
- Remove vendored libs and build them from npm using esbuild
- Switch from JSZip to zip.js
Diffstat (limited to 'ext/js/dom')
-rw-r--r-- | ext/js/dom/document-focus-controller.js | 2 | ||||
-rw-r--r-- | ext/js/dom/document-util.js | 11 | ||||
-rw-r--r-- | ext/js/dom/dom-data-binder.js | 10 | ||||
-rw-r--r-- | ext/js/dom/dom-text-scanner.js | 6 | ||||
-rw-r--r-- | ext/js/dom/html-template-collection.js | 2 | ||||
-rw-r--r-- | ext/js/dom/native-simple-dom-parser.js | 2 | ||||
-rw-r--r-- | ext/js/dom/panel-element.js | 4 | ||||
-rw-r--r-- | ext/js/dom/popup-menu.js | 4 | ||||
-rw-r--r-- | ext/js/dom/sandbox/css-style-applier.js | 2 | ||||
-rw-r--r-- | ext/js/dom/scroll-element.js | 2 | ||||
-rw-r--r-- | ext/js/dom/selector-observer.js | 2 | ||||
-rw-r--r-- | ext/js/dom/simple-dom-parser.js | 6 | ||||
-rw-r--r-- | ext/js/dom/text-source-element.js | 9 | ||||
-rw-r--r-- | ext/js/dom/text-source-range.js | 9 |
14 files changed, 33 insertions, 38 deletions
diff --git a/ext/js/dom/document-focus-controller.js b/ext/js/dom/document-focus-controller.js index 937a7c13..501d1fad 100644 --- a/ext/js/dom/document-focus-controller.js +++ b/ext/js/dom/document-focus-controller.js @@ -22,7 +22,7 @@ * keyboard shortcuts (e.g. arrow keys) not controlling page scroll. Instead, this class will manually * focus a dummy element inside the main content, which gives keyboard scroll focus to that element. */ -class DocumentFocusController { +export class DocumentFocusController { /** * Creates a new instance of the class. * @param {?string} autofocusElementSelector A selector string which can be used to specify an element which diff --git a/ext/js/dom/document-util.js b/ext/js/dom/document-util.js index 9bca951b..d379192c 100644 --- a/ext/js/dom/document-util.js +++ b/ext/js/dom/document-util.js @@ -16,16 +16,15 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * DOMTextScanner - * TextSourceElement - * TextSourceRange - */ +import {EventListenerCollection} from '../core.js'; +import {DOMTextScanner} from './dom-text-scanner.js'; +import {TextSourceElement} from './text-source-element.js'; +import {TextSourceRange} from './text-source-range.js'; /** * This class contains utility functions related to the HTML document. */ -class DocumentUtil { +export class DocumentUtil { /** * Options to configure how element detection is performed. * @typedef {object} GetRangeFromPointOptions diff --git a/ext/js/dom/dom-data-binder.js b/ext/js/dom/dom-data-binder.js index fca5cd9f..4da5b0c2 100644 --- a/ext/js/dom/dom-data-binder.js +++ b/ext/js/dom/dom-data-binder.js @@ -16,13 +16,11 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * DocumentUtil - * SelectorObserver - * TaskAccumulator - */ +import {TaskAccumulator} from '../general/task-accumulator.js'; +import {DocumentUtil} from './document-util.js'; +import {SelectorObserver} from './selector-observer.js'; -class DOMDataBinder { +export class DOMDataBinder { constructor({selector, createElementMetadata, compareElementMetadata, getValues, setValues, onError=null}) { this._selector = selector; this._createElementMetadata = createElementMetadata; diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js index ec4c7bd6..ccd1c90b 100644 --- a/ext/js/dom/dom-text-scanner.js +++ b/ext/js/dom/dom-text-scanner.js @@ -16,14 +16,12 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * StringUtil - */ +import {StringUtil} from '../data/sandbox/string-util.js'; /** * A class used to scan text in a document. */ -class DOMTextScanner { +export class DOMTextScanner { /** * Creates a new instance of a DOMTextScanner. * @param {Node} node The DOM Node to start at. diff --git a/ext/js/dom/html-template-collection.js b/ext/js/dom/html-template-collection.js index 4cdcf938..100ba55c 100644 --- a/ext/js/dom/html-template-collection.js +++ b/ext/js/dom/html-template-collection.js @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class HtmlTemplateCollection { +export class HtmlTemplateCollection { constructor(source) { this._templates = new Map(); diff --git a/ext/js/dom/native-simple-dom-parser.js b/ext/js/dom/native-simple-dom-parser.js index 245386bd..882469a0 100644 --- a/ext/js/dom/native-simple-dom-parser.js +++ b/ext/js/dom/native-simple-dom-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class NativeSimpleDOMParser { +export class NativeSimpleDOMParser { constructor(content) { this._document = new DOMParser().parseFromString(content, 'text/html'); } diff --git a/ext/js/dom/panel-element.js b/ext/js/dom/panel-element.js index ac283d02..9b056920 100644 --- a/ext/js/dom/panel-element.js +++ b/ext/js/dom/panel-element.js @@ -16,7 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class PanelElement extends EventDispatcher { +import {EventDispatcher} from '../core.js'; + +export class PanelElement extends EventDispatcher { constructor({node, closingAnimationDuration}) { super(); this._node = node; diff --git a/ext/js/dom/popup-menu.js b/ext/js/dom/popup-menu.js index 4ab1e049..7cae1dff 100644 --- a/ext/js/dom/popup-menu.js +++ b/ext/js/dom/popup-menu.js @@ -16,7 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class PopupMenu extends EventDispatcher { +import {EventDispatcher, EventListenerCollection} from '../core.js'; + +export class PopupMenu extends EventDispatcher { constructor(sourceElement, containerNode) { super(); this._sourceElement = sourceElement; diff --git a/ext/js/dom/sandbox/css-style-applier.js b/ext/js/dom/sandbox/css-style-applier.js index a47ef6ef..4f570bb7 100644 --- a/ext/js/dom/sandbox/css-style-applier.js +++ b/ext/js/dom/sandbox/css-style-applier.js @@ -20,7 +20,7 @@ * This class is used to apply CSS styles to elements using a consistent method * that is the same across different browsers. */ -class CssStyleApplier { +export class CssStyleApplier { /** * A CSS rule. * @typedef {object} CssRule diff --git a/ext/js/dom/scroll-element.js b/ext/js/dom/scroll-element.js index e7526db0..4b2ac70d 100644 --- a/ext/js/dom/scroll-element.js +++ b/ext/js/dom/scroll-element.js @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -class ScrollElement { +export class ScrollElement { constructor(node) { this._node = node; this._animationRequestId = null; diff --git a/ext/js/dom/selector-observer.js b/ext/js/dom/selector-observer.js index 56f97202..e0e3d4ff 100644 --- a/ext/js/dom/selector-observer.js +++ b/ext/js/dom/selector-observer.js @@ -19,7 +19,7 @@ /** * Class which is used to observe elements matching a selector in specific element. */ -class SelectorObserver { +export class SelectorObserver { /** * @function OnAddedCallback * @param {Element} element The element which was added. diff --git a/ext/js/dom/simple-dom-parser.js b/ext/js/dom/simple-dom-parser.js index 266a465c..3e84b783 100644 --- a/ext/js/dom/simple-dom-parser.js +++ b/ext/js/dom/simple-dom-parser.js @@ -16,11 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* globals - * parse5 - */ +import * as parse5 from '../../lib/parse5.js'; -class SimpleDOMParser { +export class SimpleDOMParser { constructor(content) { this._document = parse5.parse(content); this._patternHtmlWhitespace = /[\t\r\n\f ]+/g; diff --git a/ext/js/dom/text-source-element.js b/ext/js/dom/text-source-element.js index e37a3582..95534975 100644 --- a/ext/js/dom/text-source-element.js +++ b/ext/js/dom/text-source-element.js @@ -16,16 +16,15 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * DocumentUtil - * StringUtil - */ +import {StringUtil} from '../data/sandbox/string-util.js'; +import {DocumentUtil} from './document-util.js'; +import {TextSourceRange} from './text-source-range.js'; /** * This class represents a text source that is attached to a HTML element, such as an <img> * with alt text or a <button>. */ -class TextSourceElement { +export class TextSourceElement { /** * Creates a new instance of the class. * @param {Element} element The source element. diff --git a/ext/js/dom/text-source-range.js b/ext/js/dom/text-source-range.js index 8d6856b2..d5e70052 100644 --- a/ext/js/dom/text-source-range.js +++ b/ext/js/dom/text-source-range.js @@ -16,17 +16,16 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * DOMTextScanner - * DocumentUtil - */ +import {DocumentUtil} from './document-util.js'; +import {DOMTextScanner} from './dom-text-scanner.js'; +import {TextSourceElement} from './text-source-element.js'; /** * This class represents a text source that comes from text nodes in the document. * Sometimes a temporary "imposter" element is created and used to store the text. * This element is typically hidden from the page and removed after scanning has completed. */ -class TextSourceRange { +export class TextSourceRange { /** * Creates a new instance of the class. * @param {Range} range The selection range. |