File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
debug_toolbar/static/debug_toolbar/js Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,29 @@ function insertBrowserTiming() {
55 timingEnd = performance . timing . loadEventEnd ,
66 totalTime = timingEnd - timingOffset ;
77 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+ }
915 }
1016 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+ }
1731 return width < 1 ? "2px" : width + "%" ;
1832 }
1933 function addRow ( tbody , stat , endStat ) {
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ Change log
44Pending
55-------
66
7+ * Added protection against division by 0 in timer.js
78* Auto-update History panel for JavaScript ``fetch `` requests.
89* Support `HTMX boosting <https://htmx.org/docs/#boosting/ >`__ and
910 re-rendering the toolbar after the DOM has been replaced. This reworks
1011 the JavaScript integration to put most event handlers on document.body.
1112 This means we'll have slightly slower performance, but it's easier
1213 to handle re-rendering the toolbar when the DOM has been replaced.
1314
14-
15153.7.0 (2022-09-25)
1616------------------
1717
You can’t perform that action at this time.
0 commit comments