diff --git a/lib/core/base/rule.js b/lib/core/base/rule.js index 2a4b317c35..48685bc999 100644 --- a/lib/core/base/rule.js +++ b/lib/core/base/rule.js @@ -479,6 +479,7 @@ function findCheckResults(nodes, checkID) { var checks = getAllChecks(nodeResult); checks.forEach(function(checkResult) { if (checkResult.id === checkID) { + checkResult.node = nodeResult.node; checkResults.push(checkResult); } }); @@ -534,6 +535,10 @@ Rule.prototype.after = function(result, options) { var afterResults = check.after(beforeResults, option); beforeResults.forEach(function(item) { + // only add the node property for the check.after so we can + // look at which iframe a check result came from, but we don't + // want it for the final results object + delete item.node; if (afterResults.indexOf(item) === -1) { item.filtered = true; } diff --git a/test/core/base/rule.js b/test/core/base/rule.js index 995c0d0f7c..caeb97ccd4 100644 --- a/test/core/base/rule.js +++ b/test/core/base/rule.js @@ -1518,6 +1518,52 @@ describe('Rule', function() { assert.isTrue(success); }); + it('should add the check node to the check result', function() { + var success = false; + + var rule = new Rule( + { + id: 'cats', + any: ['cats'] + }, + { + checks: { + cats: { + id: 'cats', + enabled: true, + after: function(results) { + assert.equal(results[0].node, 'customNode'); + success = true; + return results; + } + } + } + } + ); + + rule.after( + { + id: 'cats', + nodes: [ + { + all: [], + none: [], + any: [ + { + id: 'cats', + result: true + } + ], + node: 'customNode' + } + ] + }, + { checks: { cats: { options: { dogs: true } } } } + ); + + assert.isTrue(success); + }); + it('should filter removed checks', function() { var rule = new Rule( {