private reduceResults()

in packages/axe-result-converter/src/axe-results-reducer.ts [33:66]


    private reduceResults(url: string, accumulatedResults: AxeResultsList, currentResults: axe.Result[]): void {
        if (currentResults) {
            for (const currentResult of currentResults) {
                if (currentResult) {
                    for (const node of currentResult.nodes) {
                        if (node) {
                            const selectorInfo = this.getSelectorInfo(node);
                            const fingerprint = this.getElementFingerprint(currentResult, node, selectorInfo);
                            const matchingResult = accumulatedResults.get(fingerprint);

                            if (matchingResult !== undefined) {
                                if (!matchingResult.urls.some((u) => u === url)) {
                                    matchingResult.urls.push(url);
                                }
                            } else {
                                const result: AxeResult = {
                                    ...currentResult,
                                    nodes: [],
                                    urls: [url],
                                    urlInfos: [], // This will get populated downstream
                                    junctionNode: {
                                        ...node,
                                        selectors: selectorInfo.selectors,
                                    },
                                    fingerprint,
                                };
                                accumulatedResults.add(fingerprint, result);
                            }
                        }
                    }
                }
            }
        }
    }