11import nodeSerializer from './node-serializer' ;
22import getAllChecks from './get-all-checks' ;
33import 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 */
7677function 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
112124function nodeIndexSort ( nodeIndexesA = [ ] , nodeIndexesB = [ ] ) {
0 commit comments