mirror of
https://github.com/dream-num/univer.git
synced 2026-09-19 02:18:42 +08:00
fix(render): skip invalid shape stroke widths (#7370)
This commit is contained in:
@@ -141,6 +141,23 @@ describe('basic shape and position helpers', () => {
|
||||
expect(ctx.restore).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('skips non-positive and non-finite stroke widths', () => {
|
||||
for (const strokeWidth of [0, -1, Number.NaN, Number.POSITIVE_INFINITY]) {
|
||||
const ctx = createShapeCtx();
|
||||
|
||||
Rect.drawWith(ctx, {
|
||||
width: 80,
|
||||
height: 32,
|
||||
fill: '#ffffff',
|
||||
stroke: '#ff0000',
|
||||
strokeWidth,
|
||||
});
|
||||
|
||||
expect(ctx.fill).toHaveBeenCalled();
|
||||
expect(ctx.stroke).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it('draws a rounded visual rect centered in the interaction bounds', () => {
|
||||
const rect = new Rect('rect-visual', {
|
||||
width: 80,
|
||||
|
||||
@@ -283,7 +283,7 @@ export abstract class Shape<T extends IShapeProps> extends BaseObject {
|
||||
|
||||
// let { scaleX, scaleY } = props;
|
||||
// const { scaleX = 1, scaleY = 1 } = ctx.getScale();
|
||||
if (!stroke || strokeWidth === 0) {
|
||||
if (!stroke || strokeWidth === undefined || !Number.isFinite(strokeWidth) || strokeWidth <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user