Skip to content

Commit 2e22663

Browse files
committed
Iframe error merging logic added
1 parent c7b3fa4 commit 2e22663

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/core/utils/merge-results.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import nodeSerializer from './node-serializer';
22
import getAllChecks from './get-all-checks';
33
import findBy from './find-by';
4+
import mergeErrors from './merge-errors';
45

56
/**
67
* Adds the owning frame's CSS selector onto each instance of DqElement
@@ -75,13 +76,20 @@ function normalizeResult(result) {
7576
*/
7677
function mergeResults(frameResults, options) {
7778
const mergedResult = [];
79+
let mergedErrors = {};
7880
frameResults.forEach(frameResult => {
7981
const results = normalizeResult(frameResult);
8082
if (!results || !results.length) {
8183
return;
8284
}
8385

8486
const frameSpec = getFrameSpec(frameResult);
87+
if (results[results.length - 1].errorsObj) {
88+
const error = results.pop();
89+
delete error.errorsObj;
90+
mergedErrors = mergeErrors(mergedErrors, error, frameSpec);
91+
}
92+
8593
results.forEach(ruleResult => {
8694
if (ruleResult.nodes && frameSpec) {
8795
pushFrame(ruleResult.nodes, options, frameSpec);
@@ -106,7 +114,11 @@ function mergeResults(frameResults, options) {
106114
});
107115
}
108116
});
109-
return mergedResult;
117+
118+
if (Object.keys(mergedErrors).length === 0) {
119+
return mergedResult;
120+
}
121+
return [...mergedResult, { ...mergedErrors, errorsObj: true }];
110122
}
111123

112124
function nodeIndexSort(nodeIndexesA = [], nodeIndexesB = []) {

0 commit comments

Comments
 (0)