Skip to content

Commit 2af75c4

Browse files
fix(coverage): Add build-time option to not update total row
1 parent e40fa51 commit 2af75c4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/coverage/inject_me.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,28 @@ function linkifyRow(tr) {
3636
function linkifyAll() {
3737
document.querySelectorAll('tr.region').forEach(linkifyRow);
3838
}
39+
const PREVENT_FILTER_TOTAL = true;
40+
function preventUpdateTotalCell(cell) {
41+
let target = cell.classList;
42+
let oldContains = target.contains.bind(target);
43+
function newContains(value) {
44+
// Tell the Coverage.py code that all entries in total row are 'name'
45+
// so it doesn't try to modify them.
46+
if (value == "name") return true;
47+
return oldContains(value);
48+
}
49+
target.contains = newContains;
50+
}
51+
function preventUpdateTotal() {
52+
[...document.querySelector('table.index').tFoot.rows[0].cells]
53+
.forEach(preventUpdateTotalCell);
54+
}
3955
addEventListener('load', () => {
4056
if(document.body.classList.contains("indexfile")) {
4157
setColors();
4258
linkifyAll();
59+
if(PREVENT_FILTER_TOTAL) {
60+
preventUpdateTotal();
61+
}
4362
}
4463
});

0 commit comments

Comments
 (0)