happo 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9a8cddb3cdd182db6d8d96d32b9a81c5802f449
4
- data.tar.gz: 6d9726df428ef2da13115dbfedbf739d27e0875d
3
+ metadata.gz: 4f44c560afe02096d68d9a04a2f2f8bb787768ae
4
+ data.tar.gz: a88fa0dcd66c6c1cd21b2dfd05914da55a0b5814
5
5
  SHA512:
6
- metadata.gz: f1b0f14bc41131d94b70ae1efc96bcde6e717958634dcb72cdd73438cc503b0a2aeadc1b7336589df246c1765c6c589ae1d313c4cba96c04b29d8d13ffb520c5
7
- data.tar.gz: af494cf1cc7b4d18cf2aae3ab6941157f35a2cc474d9e7e1e3ae3c5661884cb54d838baf26a1939e02b869f4add0a1f6b7bb0739415cb1f8fb71d2b35b1fb90d
6
+ metadata.gz: 47ed2b3c591ccfa1acf1cbf47bc917fd2f71c917b9d8de65e97ca40fc8d4fa428e458bbd3a6c616e7bc7b8b1dffddec055a5855f50514f49b7f0f403d9c0650a
7
+ data.tar.gz: bef158db3def1a19b72caa132a87abcf0cfe16298112fb0559d0e9f0637a32d3274cafce16557cc50a6935f1d9ad52745767589c0fd0a3cbfe3c236c793c6491
@@ -240,25 +240,19 @@ Swiper.propTypes = {
240
240
  function SideBySide({ previous, current }) {
241
241
  return (
242
242
  <div className='SideBySide'>
243
- <div className='SideBySide__image'>
244
- <img
245
- role='presentation'
246
- src={previous}
247
- />
248
- <div className='SideBySide__caption'>
249
- Before
250
- </div>
251
- </div>
243
+ <img
244
+ className='SideBySide__image'
245
+ role='presentation'
246
+ src={previous}
247
+ title='Before'
248
+ />
252
249
  {' '}
253
- <div className='SideBySide__image'>
254
- <img
255
- role='presentation'
256
- src={current}
257
- />
258
- <div className='SideBySide__caption'>
259
- After
260
- </div>
261
- </div>
250
+ <img
251
+ className='SideBySide__image'
252
+ role='presentation'
253
+ src={current}
254
+ title='After'
255
+ />
262
256
  </div>
263
257
  );
264
258
  }
@@ -10,7 +10,6 @@
10
10
  window.happo = {
11
11
  defined: {},
12
12
  fdefined: [],
13
- currentRenderedElement: undefined,
14
13
  errors: [],
15
14
 
16
15
  define: function define(description, func, options) {
@@ -99,8 +98,7 @@ window.happo = {
99
98
  *
100
99
  * @param {Object} renderedElement
101
100
  */
102
- cleanOutElement: function cleanOutElement(renderedElement) {
103
- renderedElement.parentNode.removeChild(renderedElement);
101
+ cleanOutElement: function cleanOutElement() {
104
102
  },
105
103
 
106
104
  /**
@@ -121,10 +119,8 @@ window.happo = {
121
119
  }
122
120
 
123
121
  // Clear out the body of the document
124
- if (this.currentRenderedElement) {
125
- this.cleanOutElement(this.currentRenderedElement);
126
- }
127
122
  while (document.body.firstChild) {
123
+ this.cleanOutElement(document.body.firstChild);
128
124
  document.body.removeChild(document.body.firstChild);
129
125
  }
130
126
 
@@ -133,8 +129,8 @@ window.happo = {
133
129
  // The function takes an argument, which is a callback that is called
134
130
  // once it is done executing. This can be used to write functions that
135
131
  // have asynchronous code in them.
136
- this.tryAsync(func).then(function (elem) {
137
- doneFunc(this.processElem(currentExample, elem));
132
+ this.tryAsync(func).then(function () {
133
+ doneFunc(this.processExample(currentExample));
138
134
  }.bind(this)).catch(function (error) {
139
135
  doneFunc(this.handleError(currentExample, error));
140
136
  }.bind(this));
@@ -146,15 +142,15 @@ window.happo = {
146
142
  if (result instanceof Promise) {
147
143
  // The function returned a promise, so we need to wait for it to
148
144
  // resolve before proceeding.
149
- result.then(function (elem) {
150
- doneFunc(this.processElem(currentExample, elem));
145
+ result.then(function () {
146
+ doneFunc(this.processExample(currentExample));
151
147
  }.bind(this)).catch(function (error) {
152
148
  doneFunc(this.handleError(currentExample, error));
153
149
  }.bind(this));
154
150
  } else {
155
151
  // The function did not return a promise, so we assume it gave us an
156
152
  // element that we can process immediately.
157
- doneFunc(this.processElem(currentExample, result));
153
+ doneFunc(this.processExample(currentExample));
158
154
  }
159
155
  }
160
156
  } catch (error) {
@@ -197,38 +193,36 @@ window.happo = {
197
193
  }
198
194
  },
199
195
 
200
- // This function gets the full size of the given node, including all
201
- // descendent nodes. This allows us to ensure that the screenshot includes
202
- // absolutely positioned elements. It is important that this is fast, since we
203
- // may be iterating over a high number of nodes.
204
- getFullRect: function getFullRect(node) {
205
- this.removeScrollbars(node);
206
-
207
- var rect = node.getBoundingClientRect();
208
-
196
+ // This function gets the full size of children in the document body,
197
+ // including all descendent nodes. This allows us to ensure that the
198
+ // screenshot includes absolutely positioned elements. It is important that
199
+ // this is fast, since we may be iterating over a high number of nodes.
200
+ getFullRect: function getFullRect() {
209
201
  // Set up the initial object that we will mutate in our recursive function.
210
202
  var box = {
211
- bottom: rect.bottom,
212
- left: rect.left,
213
- right: rect.right,
214
- top: rect.top,
203
+ bottom: 0,
204
+ left: 0,
205
+ right: 0,
206
+ top: 0,
215
207
  };
216
208
 
217
- // getBoundingClientRect does not include margin, so we need to use
218
- // getComputedStyle. Since this is slow and the margin of descendent
219
- // elements is significantly less likely to matter, let's include the margin
220
- // only from the topmost node.
221
- var computedStyle = window.getComputedStyle(node);
222
- box.bottom += parseInt(computedStyle.getPropertyValue('margin-bottom'), 10);
223
- box.left -= parseInt(computedStyle.getPropertyValue('margin-left'), 10);
224
- box.right += parseInt(computedStyle.getPropertyValue('margin-right'), 10);
225
- box.top -= parseInt(computedStyle.getPropertyValue('margin-top'), 10);
226
-
227
209
  // If there are any children, we want to iterate over them recursively,
228
210
  // mutating our box object along the way to expand to include all descendent
229
211
  // nodes.
230
- for (var i = 0; i < node.children.length; i++) {
231
- this.getFullRectRecursive(node.children[i], box);
212
+ for (var i = 0; i < document.body.children.length; i++) {
213
+ var node = document.body.children[i];
214
+
215
+ this.getFullRectRecursive(node, box);
216
+
217
+ // getBoundingClientRect does not include margin, so we need to use
218
+ // getComputedStyle. Since this is slow and the margin of descendent
219
+ // elements is significantly less likely to matter, let's include the
220
+ // margin only from the topmost nodes.
221
+ var computedStyle = window.getComputedStyle(node);
222
+ box.bottom += parseInt(computedStyle.getPropertyValue('margin-bottom'), 10);
223
+ box.left -= parseInt(computedStyle.getPropertyValue('margin-left'), 10);
224
+ box.right += parseInt(computedStyle.getPropertyValue('margin-right'), 10);
225
+ box.top -= parseInt(computedStyle.getPropertyValue('margin-top'), 10);
232
226
  }
233
227
 
234
228
  // As the last step, we calculate the width and height for the box. This is
@@ -247,23 +241,11 @@ window.happo = {
247
241
  return box;
248
242
  },
249
243
 
250
- processElem: function processElem(currentExample, elem) {
244
+ processExample: function processExample(currentExample) {
251
245
  try {
252
- this.currentRenderedElement = elem;
253
-
254
- var rect;
255
- if (currentExample.options.snapshotEntireScreen) {
256
- rect = {
257
- width: window.innerWidth,
258
- height: window.innerHeight,
259
- top: 0,
260
- left: 0,
261
- };
262
- } else {
263
- // Note that this method returns floats, so we need to round those off
264
- // to integers before returning.
265
- rect = this.getFullRect(elem);
266
- }
246
+ // Note that this method returns floats, so we need to round those off
247
+ // to integers before returning.
248
+ var rect = this.getFullRect();
267
249
 
268
250
  return {
269
251
  description: currentExample.description,
@@ -123,25 +123,5 @@ body {
123
123
  }
124
124
 
125
125
  .SideBySide__image {
126
- display: inline-block;
127
- line-height: 0;
128
- position: relative;
129
126
  vertical-align: top;
130
127
  }
131
-
132
- .SideBySide__caption {
133
- background-color: #666666;
134
- bottom: 0;
135
- color: #ffffff;
136
- font-size: 10px;
137
- line-height: 1;
138
- opacity: 0;
139
- padding: 3px 6px;
140
- position: absolute;
141
- right: 0;
142
- transition: opacity .2s;
143
- }
144
-
145
- .SideBySide__image:hover .SideBySide__caption {
146
- opacity: 1;
147
- }
data/lib/happo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Happo
3
- VERSION = '2.6.0'
3
+ VERSION = '2.7.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-02 00:00:00.000000000 Z
12
+ date: 2016-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chunky_png