Skip to content

Commit

Permalink
extract the default options object into a constants and rename the va…
Browse files Browse the repository at this point in the history
…riable to something that makes sense
  • Loading branch information
ndelangen committed Nov 24, 2021
1 parent 4a99981 commit c61f83d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/channel-postmessage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface BufferedEvent {

export const KEY = 'storybook-channel';

const defaultEventOptions = { allowFunction: true, maxDepth: 25 };

// TODO: we should export a method for opening child windows here and keep track of em.
// that way we can send postMessage to child windows as well, not just iframe
// https://stackoverflow.com/questions/6340160/how-to-get-the-references-of-all-already-opened-child-windows
Expand Down Expand Up @@ -73,7 +75,7 @@ export class PostmsgTransport {
lazyEval,
} = options || {};

const c = Object.fromEntries(
const eventOptions = Object.fromEntries(
Object.entries({
allowRegExp,
allowFunction,
Expand All @@ -88,9 +90,9 @@ export class PostmsgTransport {
);

const stringifyOptions = {
...{ allowFunction: true, maxDepth: 25 },
...defaultEventOptions,
...(global.CHANNEL_OPTIONS || {}),
...c,
...eventOptions,
};

// backwards compat: convert depth to maxDepth
Expand Down

0 comments on commit c61f83d

Please sign in to comment.