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

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

Build:
Build:
LAST BUILD BRANCH: add_gateway_code_paypal_complete_2
DEFAULT BRANCH: master
Ran 18 Oct 2019 08:30PM UTC
Files 69
Run time 6s
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

18 Oct 2019 08:25PM UTC coverage: 91.95% (+79.2%) from 12.705%
BROWSER=chrome_headless ARTIFACTS_BUCKET=recurly-js REPORT_COVERAGE=true

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

Source Files on job 2788.1 (BROWSER=chrome_headless ARTIFACTS_BUCKET=recurly-js REPORT_COVERAGE=true)
  • Tree
  • List 0
  • Changed 64
  • Source Changed 0
  • Coverage Changed 64
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 1052
  • Travis Job 2788.1
  • 347fda97 on github
  • Prev Job for BROWSER=chrome_headless ARTIFACTS_BUCKET=recurly-js REPORT_COVERAGE=true on elements (#2787.1)
  • Next Job for BROWSER=chrome_headless REPORT_COVERAGE=true on elements (#2829.2)
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