• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

recurly / recurly-js / 2788
92%
master: 91%

Build:
Build:
LAST BUILD BRANCH: add_gateway_code_paypal_complete_2
DEFAULT BRANCH: master
Ran 18 Oct 2019 08:30PM UTC
Jobs 1
Files 69
Run time 7s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
2788

push

travis-ci

chrissrogers
Purges bus recipients more precisely on `recurly.configure`

Introduction

Re-configuration of a recurly instance introduces a potential to abandon
hostedFields instances, say if the new configuration blob assigns a new
DOM target for one of the hosted fields. The routine to handle this is
contained within `recurly.parent`.

For a long time, it was sufficient to discard the recurly.bus when this
happened. The bus was safely considered to be dirty, and there were no
cases where a bus recipient may be lost in the discard procedure.

The Problem

However, with the introduction of Frame, and its newer dependents, we
came to add recipients to the bus that require the bus to persist across
the lifetime of their recurly instance.

Consider the following:

```js
const recurly = new Recurly();
const frame = recurly.Frame();
frame.attach(document.querySelector('#my-target'));
```

At this point, `frame` has added itself to `recurly.bus`, so that
messages that hit the parent window will dispatch to the `frame`
instance. Then let's say, while the frame is open, you do the following:

```js
recurly.configure({ fields: { card: { selector: '#new-selector' } } });
```

At this point, `recurly.parent` will destroy its `HostedFields` instance,
and create a new one targetting the new selector. It will then discard
`recurly.bus` and create a new one. This is a problem for our `frame`
instance, as it is listening to a bus that has been destroyed!

The Solution

This is a very sensitive aspect of a Recurly instance. The `recurly.bus`
is crucial for all messaging between Recurly.js classes, and
`recurly.parent` must be able to intelligently discard and re-create
HostedFields as configuration changes, and do so in a clean manner.

I determined that the bus was only being discarded in order to remove
any now-inactive hosted fields. Thus, it was just a matter of
instructing HostedField and HostedFields instances to remove themselves
from their bus when they are destroyed. This... (continued)

1061 of 1341 branches covered (79.12%)

2410 of 2621 relevant lines covered (91.95%)

8154.89 hits per line

Jobs
ID Job ID Ran Files Coverage
1 2788.1 (BROWSER=chrome_headless ARTIFACTS_BUCKET=recurly-js REPORT_COVERAGE=true) 18 Oct 2019 08:30PM UTC 0
91.95
Travis Job 2788.1
Source Files on build 2788
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #2788
  • 347fda97 on github
  • Prev Build on elements (#2787)
  • Next Build on elements (#2829)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc