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 {
*/
this.ready = new Promise(resolve => {
this._listeners.add(window, 'message', event => {
const messageEvent = /** @type {MessageEvent} */ (event);
if (messageEvent.data?.type === 'hypothesisSidebarReady') {
this._sidebarRPC.createChannel(messageEvent.ports[0]);
const { data, ports } = /** @type {MessageEvent} */ (event);
if (data?.type === 'hypothesisSidebarReady') {
this._sidebarRPC.createChannel(ports[0]);
resolve();
}
});
......@@ -215,9 +215,9 @@ export default class Sidebar {
// directly to the sidebar during a window's 'unload' event.
// See https://bugs.webkit.org/show_bug.cgi?id=231167.
this._listeners.add(window, 'message', event => {
const messageData = /** @type {MessageEvent} */ (event).data;
if (messageData?.type === 'hypothesisGuestUnloaded') {
this._sidebarRPC.call('destroyFrame', messageData.frameIdentifier);
const { data } = /** @type {MessageEvent} */ (event);
if (data?.type === 'hypothesisGuestUnloaded') {
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