File tree 2 files changed +22
-8
lines changed
debug_toolbar/static/debug_toolbar/js
2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,29 @@ function insertBrowserTiming() {
5
5
timingEnd = performance . timing . loadEventEnd ,
6
6
totalTime = timingEnd - timingOffset ;
7
7
function getLeft ( stat ) {
8
- return ( ( performance . timing [ stat ] - timingOffset ) / totalTime ) * 100.0 ;
8
+ if ( totalTime !== 0 ) {
9
+ return (
10
+ ( ( performance . timing [ stat ] - timingOffset ) / totalTime ) * 100.0
11
+ ) ;
12
+ } else {
13
+ return 0 ;
14
+ }
9
15
}
10
16
function getCSSWidth ( stat , endStat ) {
11
- let width =
12
- ( ( performance . timing [ endStat ] - performance . timing [ stat ] ) /
13
- totalTime ) *
14
- 100.0 ;
15
- // Calculate relative percent (same as sql panel logic)
16
- width = ( 100.0 * width ) / ( 100.0 - getLeft ( stat ) ) ;
17
+ let width = 0 ;
18
+ if ( totalTime !== 0 ) {
19
+ width =
20
+ ( ( performance . timing [ endStat ] - performance . timing [ stat ] ) /
21
+ totalTime ) *
22
+ 100.0 ;
23
+ }
24
+ const denominator = 100.0 - getLeft ( stat ) ;
25
+ if ( denominator !== 0 ) {
26
+ // Calculate relative percent (same as sql panel logic)
27
+ width = ( 100.0 * width ) / denominator ;
28
+ } else {
29
+ width = 0 ;
30
+ }
17
31
return width < 1 ? "2px" : width + "%" ;
18
32
}
19
33
function addRow ( tbody , stat , endStat ) {
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ Change log
4
4
Pending
5
5
-------
6
6
7
+ * Added protection against division by 0 in timer.js
7
8
* Auto-update History panel for JavaScript ``fetch `` requests.
8
9
* Support `HTMX boosting <https://htmx.org/docs/#boosting/ >`__ and
9
10
re-rendering the toolbar after the DOM has been replaced. This reworks
10
11
the JavaScript integration to put most event handlers on document.body.
11
12
This means we'll have slightly slower performance, but it's easier
12
13
to handle re-rendering the toolbar when the DOM has been replaced.
13
14
14
-
15
15
3.7.0 (2022-09-25)
16
16
------------------
17
17
You can’t perform that action at this time.
0 commit comments