Commit 05b6a932 authored by Robert Knight's avatar Robert Knight

Use destructuring to make some code more succinct

parent c56cf3fa
...@@ -202,9 +202,9 @@ export default class Sidebar { ...@@ -202,9 +202,9 @@ export default class Sidebar {
*/ */
this.ready = new Promise(resolve => { this.ready = new Promise(resolve => {
this._listeners.add(window, 'message', event => { this._listeners.add(window, 'message', event => {
const messageEvent = /** @type {MessageEvent} */ (event); const { data, ports } = /** @type {MessageEvent} */ (event);
if (messageEvent.data?.type === 'hypothesisSidebarReady') { if (data?.type === 'hypothesisSidebarReady') {
this._sidebarRPC.createChannel(messageEvent.ports[0]); this._sidebarRPC.createChannel(ports[0]);
resolve(); resolve();
} }
}); });
...@@ -215,9 +215,9 @@ export default class Sidebar { ...@@ -215,9 +215,9 @@ export default class Sidebar {
// directly to the sidebar during a window's 'unload' event. // directly to the sidebar during a window's 'unload' event.
// See https://bugs.webkit.org/show_bug.cgi?id=231167. // See https://bugs.webkit.org/show_bug.cgi?id=231167.
this._listeners.add(window, 'message', event => { this._listeners.add(window, 'message', event => {
const messageData = /** @type {MessageEvent} */ (event).data; const { data } = /** @type {MessageEvent} */ (event);
if (messageData?.type === 'hypothesisGuestUnloaded') { if (data?.type === 'hypothesisGuestUnloaded') {
this._sidebarRPC.call('destroyFrame', messageData.frameIdentifier); this._sidebarRPC.call('destroyFrame', data.frameIdentifier);
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment