diff --git a/lib/renderer/web-view/web-view-attributes.ts b/lib/renderer/web-view/web-view-attributes.ts index 07030b7015f7..68425a3ecbef 100644 --- a/lib/renderer/web-view/web-view-attributes.ts +++ b/lib/renderer/web-view/web-view-attributes.ts @@ -11,9 +11,13 @@ const resolveURL = function (url?: string | null) { return a.href } +interface MutationHandler { + handleMutation (_oldValue: any, _newValue: any): any; +} + // Attribute objects. // Default implementation of a WebView attribute. -class WebViewAttribute { +class WebViewAttribute implements MutationHandler { public value: any; public ignoreMutation = false; @@ -55,7 +59,7 @@ class WebViewAttribute { } // Called when the attribute's value changes. - public handleMutation (..._args: Array): any {} + public handleMutation: MutationHandler['handleMutation'] = () => undefined as any } // An attribute that is treated as a Boolean. @@ -81,7 +85,7 @@ class PartitionAttribute extends WebViewAttribute { super(WEB_VIEW_CONSTANTS.ATTRIBUTE_PARTITION, webViewImpl) } - public handleMutation (oldValue: any, newValue: any) { + public handleMutation = (oldValue: any, newValue: any) => { newValue = newValue || '' // The partition cannot change if the webview has already navigated. @@ -124,7 +128,7 @@ class SrcAttribute extends WebViewAttribute { this.observer.takeRecords() } - public handleMutation (oldValue: any, newValue: any) { + public handleMutation = (oldValue: any, newValue: any) => { // Once we have navigated, we don't allow clearing the src attribute. // Once enters a navigated state, it cannot return to a // placeholder state. diff --git a/lib/renderer/web-view/web-view-element.ts b/lib/renderer/web-view/web-view-element.ts index 26ac4e0badf1..098dca0ff8c8 100644 --- a/lib/renderer/web-view/web-view-element.ts +++ b/lib/renderer/web-view/web-view-element.ts @@ -9,7 +9,7 @@ // modules must be passed from outside, all included files must be plain JS. import { WEB_VIEW_CONSTANTS } from '@electron/internal/renderer/web-view/web-view-constants' -import { WebViewImpl, webViewImplModule } from '@electron/internal/renderer/web-view/web-view-impl' +import { WebViewImpl as IWebViewImpl, webViewImplModule } from '@electron/internal/renderer/web-view/web-view-impl' // Return a WebViewElement class that is defined in this context. const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof webViewImplModule) => { @@ -41,7 +41,7 @@ const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof } connectedCallback () { - const internal = v8Util.getHiddenValue(this, 'internal') + const internal = v8Util.getHiddenValue(this, 'internal') if (!internal) { return } @@ -53,14 +53,14 @@ const defineWebViewElement = (v8Util: NodeJS.V8UtilBinding, webViewImpl: typeof } attributeChangedCallback (name: string, oldValue: any, newValue: any) { - const internal = v8Util.getHiddenValue(this, 'internal') + const internal = v8Util.getHiddenValue(this, 'internal') if (internal) { internal.handleWebviewAttributeMutation(name, oldValue, newValue) } } disconnectedCallback () { - const internal = v8Util.getHiddenValue(this, 'internal') + const internal = v8Util.getHiddenValue(this, 'internal') if (!internal) { return }