Skip to content

v6.0.0

Compare
Choose a tag to compare
@Aaronius Aaronius released this 09 Jul 03:11
· 22 commits to master since this release

With a major release comes breaking changes. Here's what you need to know:

NotInIframe error removed

What

The NotInIframe error, which was thrown if connectToParent was called from outside of an iframe, has been removed. Fixes #61.

Why

Previously, if a call was made to connectToParent from outside of an iframe, Penpal would throw an error with the NotInIframe error code. While this was a nice idea, it didn't play well with Cypress. Cypress by default attempts to "modify obstructive code". In other words, if any JavaScript attempts to perform framebusting, Cypress tries to modify the code since such techniques prevent Cypress from working properly. As it turns out, Penpal's check to see if it was running inside of an iframe was not performing framebusting, but Cypress would see it as obstructive code anyway and attempt to modify it, which would actually break testing with Cypress + Penpal entirely. The workaround wasn't great and, given that Penpal's check wasn't providing a lot of value, I decided it would be in consumers' interest to remove the check.

ConnectionDestroyed error reduced in scope

What

Previously, Penpal would reject the connection promise with an error containing the ConnectionDestroyed error code if the consumer called connection.destroy before a connection was made. Fixes #51.

Why

When a consumer calls destroy, they are intentionally destroying the connection and shouldn't be forced to handle a rejected promise as a consequence. It's not an exceptional use case, so it does not merit a rejection. This change should lower development burden, as described in #51.

The ConnectionDestroyed error is still thrown if a child or parent method is called after a connection has been destroyed.

Exported types

What

This is not a breaking change. The following TypeScript types are now exported as named exports: Connection, AsyncMethodReturns, CallSender, Methods, and PenpalError types. Fixes #67.

Why

TypeScript types could previously (and still can) be imported through a child path as follows:

import { Connection } from 'penpal/lib/types';

but that made them less discoverable and the fact that they could be relied on was only implicit. They are now named exports on the top-level module, so they can now be imported as follows:

import { Connection } from 'penpal';