@brightspace-ui/testing 1.12.0 → 1.12.1
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.
- package/package.json +1 -1
- package/src/browser/vdiff.js +6 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@brightspace-ui/testing",
|
|
3
3
|
"description": "Utilities for testing front-end components and applications",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.12.
|
|
5
|
+
"version": "1.12.1",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . --ext .js",
|
package/src/browser/vdiff.js
CHANGED
|
@@ -29,11 +29,13 @@ function findTargets(elem) {
|
|
|
29
29
|
|
|
30
30
|
function findLargestRect(elems, margin) {
|
|
31
31
|
let largestRect = { left: Number.MAX_SAFE_INTEGER, top: Number.MAX_SAFE_INTEGER, right: 0, bottom: 0 };
|
|
32
|
+
let foundElemRect = false;
|
|
32
33
|
elems.forEach(elem => {
|
|
33
34
|
const targets = findTargets(elem);
|
|
34
35
|
targets.forEach(target => {
|
|
35
36
|
const targetRect = target.getBoundingClientRect();
|
|
36
37
|
if (targetRect.width !== 0 && targetRect.height !== 0) {
|
|
38
|
+
foundElemRect = true;
|
|
37
39
|
largestRect = {
|
|
38
40
|
left: Math.floor(Math.min(largestRect.left, targetRect.left)),
|
|
39
41
|
top: Math.floor(Math.min(largestRect.top, targetRect.top)),
|
|
@@ -43,6 +45,10 @@ function findLargestRect(elems, margin) {
|
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
47
|
});
|
|
48
|
+
// no elements had a size, so pick a reasonable rect
|
|
49
|
+
if (!foundElemRect) {
|
|
50
|
+
largestRect = { left: margin, top: margin, right: margin + 1, bottom: margin + 1 };
|
|
51
|
+
}
|
|
46
52
|
const rect = {
|
|
47
53
|
x: largestRect.left - margin,
|
|
48
54
|
y: largestRect.top - margin,
|