Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

v2.7.5

Compare
Choose a tag to compare
@trotzig trotzig released this 13 Sep 01:27
· 385 commits to master since this release

After making the change to include all DOM nodes in the snapshot (instead of using the returned node) led to it being a lot harder to control the width of the snapshot. If you use React, you probably use ReactDOM.render to render the happo example into the DOM. This usually involves creating an anonymous div that you append to the <body>. Without some clever css styling in order to make this anonymous div the right size, you'll end up with full-width snapshots. To fix that, we've added a getRootNodes function that you can use to control what nodes are used to compute the bounding rectangle.

Here's an example for React:

happo.getRootNodes = function() {
  return document.querySelectorAll('[data-reactroot]');
};

You can return a NodeList or an Array from this function.