From ff049f5d00f6fe50d25d2b844107f6bc79fbc330 Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 14 Oct 2016 20:10:06 +0200 Subject: [PATCH 1/3] fix(coverage): changed sourceEnd mapping for rule coverage to use the start of the last declaration instead of the end of the rule --- lib/coverage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coverage.js b/lib/coverage.js index 8408516bd..4a4c6915b 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -189,7 +189,7 @@ module.exports = inherit({ }.bind(this), coverageLevel.NONE); var sourceStart = getPosition(rule.position.start, opts.url, opts.map), - sourceEnd = getPosition(rule.position.end, opts.url, opts.map), + sourceEnd = getPosition(rule.declarations[rule.declarations.length -1].position.start, opts.url, opts.map), // Synchronous realpath() is used because of original method is totally synchronous and recursive, // while the order of recursive calls is important. Making the code being asynchronous won't make // much benefit considering only one async call can be executed to guarantee the calling order. From 31397342dcff608ab5ab561739ea237a0a3ede1e Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 14 Oct 2016 20:14:25 +0200 Subject: [PATCH 2/3] docs(coverage): added inline comment for changed sourceEnd --- lib/coverage.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/coverage.js b/lib/coverage.js index 4a4c6915b..f4e8f4428 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -189,6 +189,11 @@ module.exports = inherit({ }.bind(this), coverageLevel.NONE); var sourceStart = getPosition(rule.position.start, opts.url, opts.map), + // We're using the start of the last declaration here instead of the + // rule.position.end, because due for example to the use of sass + // variables and a buggy implementation of sourcemaps in both ruby sass + // as well as lib sass the rule end would map to the end of the variable + // declaration instead of the correct end of the css rule sourceEnd = getPosition(rule.declarations[rule.declarations.length -1].position.start, opts.url, opts.map), // Synchronous realpath() is used because of original method is totally synchronous and recursive, // while the order of recursive calls is important. Making the code being asynchronous won't make From 3525e334b1de2cc9af223ac25f2b8b9dd9c39ddf Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 14 Oct 2016 20:38:06 +0200 Subject: [PATCH 3/3] style(coverage): fixed eslint issue --- lib/coverage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coverage.js b/lib/coverage.js index f4e8f4428..3885380c9 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -194,7 +194,7 @@ module.exports = inherit({ // variables and a buggy implementation of sourcemaps in both ruby sass // as well as lib sass the rule end would map to the end of the variable // declaration instead of the correct end of the css rule - sourceEnd = getPosition(rule.declarations[rule.declarations.length -1].position.start, opts.url, opts.map), + sourceEnd = getPosition(rule.declarations[rule.declarations.length - 1].position.start, opts.url, opts.map), // Synchronous realpath() is used because of original method is totally synchronous and recursive, // while the order of recursive calls is important. Making the code being asynchronous won't make // much benefit considering only one async call can be executed to guarantee the calling order.