hermione-assert-view-extended
Advanced tools
Comparing version 3.2.0 to 4.0.0-0
66
index.js
@@ -8,3 +8,4 @@ 'use strict'; | ||
const redrawProps = ['redrawElements']; | ||
const otherProps = ['animationDisabled', 'customCSS', 'redraw', 'redrawTimeout']; | ||
const otherProps = ['animationDisabled', 'customCSS', 'redraw', 'redrawMode', 'redrawTimeout']; | ||
const redrawModeDefault = 'medium'; | ||
@@ -45,6 +46,7 @@ hermione.on(hermione.events.NEW_BROWSER, (browser) => { | ||
options.redraw = options.redraw === true ? 'soft' : options.redraw; | ||
options.redrawElements = !options.redrawElements.length ? ['body'] : options.redrawElements; | ||
options.redrawMode = options.redrawMode || redrawModeDefault; | ||
options.redrawElements = options.redraw && !options.redrawElements.length ? | ||
['body'] : options.redrawElements; | ||
if (options.redraw) { | ||
if (options.redraw || (options.redrawElements && options.redrawElements.length)) { | ||
styleString += options.redrawElements.join(',') + '{ will-change: transform; }'; | ||
@@ -73,3 +75,3 @@ } | ||
await browser.execute(function(styleString, redraw, redrawElements) { | ||
await browser.execute(function(styleString, redraw, redrawMode, redrawElements) { | ||
var PREFIX = 'hermione-assert-view-extended'; | ||
@@ -87,3 +89,3 @@ var head = document.head || document.getElementsByTagName('head')[0]; | ||
// Force redraw elements | ||
if (redraw && redrawElements && redrawElements.length) { | ||
if (redraw || (redrawElements && redrawElements.length)) { | ||
redrawElements.forEach(function(selector) { | ||
@@ -93,25 +95,33 @@ var element = document.querySelector(selector); | ||
if (element) { | ||
if (redraw === 'soft') { | ||
switch (redrawMode) { | ||
// Repaint | ||
window[PREFIX + '-styles'] = window[PREFIX + '-styles'] || {}; | ||
window[PREFIX + '-styles'][selector] = window[PREFIX + '-styles'][selector] || {}; | ||
window[PREFIX + '-styles'][selector].transform = element.style.transform; | ||
element.style.transform = 'translateZ(0)'; | ||
} else if (redraw === 'medium') { | ||
// Repaint | ||
var oldStylesVisibility = element.style.visibility; | ||
case 'soft': | ||
window[PREFIX + '-styles'] = window[PREFIX + '-styles'] || {}; | ||
window[PREFIX + '-styles'][selector] = window[PREFIX + '-styles'][selector] || {}; | ||
window[PREFIX + '-styles'][selector].transform = element.style.transform; | ||
element.style.transform = 'translateZ(0)'; | ||
element.style.visibility = 'hidden'; | ||
break; | ||
setTimeout(function() { | ||
element.style.visibility = oldStylesVisibility; | ||
}, 0); | ||
} else if (redraw === 'hard') { | ||
// Reflow and repaint | ||
var oldStylesDisplay = element.style.display; | ||
case 'medium': | ||
var oldStylesOpacity = element.style.opacity; | ||
element.style.display = 'none'; | ||
// No need to store this anywhere, the reference is enough | ||
element.offsetHeight; | ||
element.style.display = oldStylesDisplay; | ||
element.style.opacity = 0; | ||
// No need to store this anywhere, the reference is enough | ||
element.offsetHeight; | ||
element.style.opacity = oldStylesOpacity; | ||
break; | ||
// Reflow and repaint | ||
case 'hard': | ||
var oldStylesDisplay = element.style.display; | ||
element.style.display = 'none'; | ||
// No need to store this anywhere, the reference is enough | ||
element.offsetHeight; | ||
element.style.display = oldStylesDisplay; | ||
break; | ||
} | ||
@@ -121,3 +131,3 @@ } | ||
} | ||
}, styleString, options.redraw, options.redrawElements); | ||
}, styleString, options.redraw, options.redrawMode, options.redrawElements); | ||
@@ -130,3 +140,3 @@ if (options.redraw && options.redrawTimeout) { | ||
await browser.execute(function(redraw, redrawElements) { | ||
await browser.execute(function(redraw, redrawMode, redrawElements) { | ||
var PREFIX = 'hermione-assert-view-extended'; | ||
@@ -139,3 +149,3 @@ var head = document.head || document.getElementsByTagName('head')[0]; | ||
if (redraw === 'soft') { | ||
if ((redraw || (redrawElements && redrawElements.length)) && redrawMode === 'soft') { | ||
redrawElements.forEach(function(selector) { | ||
@@ -149,3 +159,3 @@ var element = document.querySelector(selector); | ||
} | ||
}, options.redraw, options.redrawElements); | ||
}, options.redraw, options.redrawMode, options.redrawElements); | ||
@@ -152,0 +162,0 @@ if (hooks.afterEach && typeof hooks.afterEach.call !== 'undefined') { |
{ | ||
"name": "hermione-assert-view-extended", | ||
"version": "3.2.0", | ||
"version": "4.0.0-0", | ||
"description": "Hermione plugin for extend assertView command.", | ||
@@ -19,2 +19,5 @@ "main": "index.js", | ||
"author": "Ruslan Khusnetdinov <ruslankhh@gmail.com>", | ||
"contributors": [ | ||
"Dmitry Akimov <deemidroll@gmail.com>" | ||
], | ||
"license": "MIT", | ||
@@ -21,0 +24,0 @@ "bugs": { |
@@ -26,3 +26,3 @@ # hermione-assert-view-extended | ||
animationDisabled: true, | ||
redraw: 'soft', | ||
redraw: true, | ||
// Elements will be covered with black rect. | ||
@@ -58,3 +58,4 @@ ignoreElements: [ | ||
| `globalStyles.animationDisabled` | `false` | Disable CSS animation (`transition-duration: 0s`, `animation-duration: 0s`, etc.). | | ||
| `globalStyles.redraw` | `false` | Bowser redraw page after apply styles.<br><ul><li>`'soft'`, `'medium'` — only repaint without reflow;</li><li>`'hard'` — reflow and repaint.</li></ul> | | ||
| `globalStyles.redraw` | `false` | Bowser redraw page after apply styles. It will be `true`, if you set `redrawElements`. | | ||
| `globalStyles.redrawMode` | `'medium'` | Bowser redraw page after apply styles.<br><ul><li>`'soft'` — only repaint without reflow with `transform: translateZ(0)`;</li><li>`'medium'` — reflow and repaint with `opacity: 0`;</li><li>`'hard'` — reflow and repaint with `display: none`.</li></ul> | | ||
| `globalStyles.redrawElements` | `['body']` | Elements will be redrawed. | | ||
@@ -61,0 +62,0 @@ | `globalStyles.redrawTimeout` | | Timeout after redraw elements. | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12464
150
69
2