diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-01 10:00:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 15:00:59 +0000 |
commit | dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch) | |
tree | 04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/comm/frame-ancestry-handler.js | |
parent | 2356223942a21d1683ac38eed8e7b9485f453d87 (diff) |
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style
* Rename file
* Update init
* Update config
* Remove dead code
Diffstat (limited to 'ext/js/comm/frame-ancestry-handler.js')
-rw-r--r-- | ext/js/comm/frame-ancestry-handler.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js index 31739654..3e58d57b 100644 --- a/ext/js/comm/frame-ancestry-handler.js +++ b/ext/js/comm/frame-ancestry-handler.js @@ -17,7 +17,6 @@ */ import {generateId} from '../core/utilities.js'; -import {yomitan} from '../yomitan.js'; /** * This class is used to return the ancestor frame IDs for the current frame. @@ -28,9 +27,12 @@ import {yomitan} from '../yomitan.js'; export class FrameAncestryHandler { /** * Creates a new instance. + * @param {import('../comm/cross-frame-api.js').CrossFrameAPI} crossFrameApi * @param {number} frameId The frame ID of the current frame the instance is instantiated in. */ - constructor(frameId) { + constructor(crossFrameApi, frameId) { + /** @type {import('../comm/cross-frame-api.js').CrossFrameAPI} */ + this._crossFrameApi = crossFrameApi; /** @type {number} */ this._frameId = frameId; /** @type {boolean} */ @@ -59,7 +61,7 @@ export class FrameAncestryHandler { prepare() { if (this._isPrepared) { return; } window.addEventListener('message', this._onWindowMessage.bind(this), false); - yomitan.crossFrame.registerHandlers([ + this._crossFrameApi.registerHandlers([ ['frameAncestryHandlerRequestFrameInfoResponse', this._onFrameAncestryHandlerRequestFrameInfoResponse.bind(this)] ]); this._isPrepared = true; @@ -211,7 +213,7 @@ export class FrameAncestryHandler { const more = (window !== parent); try { - const response = await yomitan.crossFrame.invoke(originFrameId, 'frameAncestryHandlerRequestFrameInfoResponse', {uniqueId, frameId, nonce, more}); + const response = await this._crossFrameApi.invoke(originFrameId, 'frameAncestryHandlerRequestFrameInfoResponse', {uniqueId, frameId, nonce, more}); if (response === null) { return; } const nonce2 = response.nonce; if (typeof nonce2 !== 'string') { return; } |