File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,7 +303,8 @@ export abstract class CanvasSurface {
303303 pixelRatio === undefined ? 'exact' : 'css-dpr'
304304 ) ;
305305 } else if ( 'useDevicePixels' in props && this . _usesLegacyDrawingBufferSizing ) {
306- this . props . useDevicePixels = props . useDevicePixels ?? false ;
306+ // Preserve the legacy setter's falsy-value normalization (notably numeric `0`).
307+ this . props . useDevicePixels = props . useDevicePixels || false ;
307308 const drawingBufferSizeProps = normalizeLegacyDrawingBufferSizeProps ( this . props ) ;
308309 this . _setDrawingBufferSizeProps (
309310 drawingBufferSizeProps . drawingBufferSizeTracking ,
Original file line number Diff line number Diff line change @@ -691,6 +691,18 @@ test('CanvasContext#new drawing buffer sizing props override and validate legacy
691691 'legacy autoResize false normalizes to no tracking'
692692 ) ;
693693
694+ legacyNumericCanvasContext . setProps ( { useDevicePixels : 0 } ) ;
695+ t . equal (
696+ legacyNumericCanvasContext . props . useDevicePixels ,
697+ false ,
698+ 'legacy setProps preserves falsy numeric normalization'
699+ ) ;
700+ t . equal (
701+ legacyNumericCanvasContext . props . pixelRatio ,
702+ 1 ,
703+ 'legacy setProps treats a falsy numeric ratio as non-device-pixel sizing'
704+ ) ;
705+
694706 const newCanvasContext = new TestCanvasContext (
695707 {
696708 drawingBufferSizeTracking : 'canvas' ,
You can’t perform that action at this time.
0 commit comments