From d90c2f7be8c01760dc19c81817d6aedd3236a4b1 Mon Sep 17 00:00:00 2001 From: Huzaifa Iftikhar Date: Sun, 30 Aug 2026 21:49:39 +0500 Subject: [PATCH] add a regression test for the fractional canvas size retinaScale kept reporting a change when the chart size had a decimal in it. the canvas stores whole pixels only so the value written back never matched the value it was compared against and every resize looked like a real one. the floor added in 12142 fixed that but nothing guarded it so this pins the second call returning false. --- test/specs/helpers.dom.tests.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/specs/helpers.dom.tests.js b/test/specs/helpers.dom.tests.js index 51957168422..66d852a32f2 100644 --- a/test/specs/helpers.dom.tests.js +++ b/test/specs/helpers.dom.tests.js @@ -278,6 +278,25 @@ describe('DOM helpers tests', function() { expect(canvas.style.height).toBe(`${chartHeight}px`); }); + it ('should stop reporting a change once a fractional size is applied', function() { + var chart = window.acquireChart({}, { + canvas: { + width: 300, + height: 150, + } + }); + + chart.width = 300.4; + chart.height = 150.2; + + // the canvas keeps whole pixels only so a fractional size still has to settle + expect(helpers.retinaScale(chart, 2, true)).toBe(true); + expect(helpers.retinaScale(chart, 2, true)).toBe(false); + + expect(chart.canvas.width).toBe(600); + expect(chart.canvas.height).toBe(300); + }); + describe('getRelativePosition', function() { it('should use offsetX/Y when available', function() { const event = {offsetX: 50, offsetY: 100};