From 97629320b79f150a0d98b546a7450ef693aa597b Mon Sep 17 00:00:00 2001 From: xile611 Date: Tue, 29 Aug 2023 16:16:26 +0800 Subject: [PATCH] fix(vscale): identity-scale `rang()` return the same value as `domain()` --- packages/vscale/__tests__/identity-scale.test.ts | 2 ++ packages/vscale/src/identity-scale.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vscale/__tests__/identity-scale.test.ts b/packages/vscale/__tests__/identity-scale.test.ts index 66d3c55..94f005d 100644 --- a/packages/vscale/__tests__/identity-scale.test.ts +++ b/packages/vscale/__tests__/identity-scale.test.ts @@ -3,6 +3,8 @@ import { IdentityScale } from '../src/identity-scale'; test('IdentityScale of any values', () => { const scale = new IdentityScale(); + expect(scale.domain()).toBeUndefined(); + expect(scale.range()).toBeUndefined(); expect(scale.scale('x')).toBe('x'); expect(scale.scale(12)).toBe(12); }); diff --git a/packages/vscale/src/identity-scale.ts b/packages/vscale/src/identity-scale.ts index 9316cb2..d205889 100644 --- a/packages/vscale/src/identity-scale.ts +++ b/packages/vscale/src/identity-scale.ts @@ -65,7 +65,7 @@ export class IdentityScale implements IBaseScale { range(_: any[]): this; range(_?: any[]): this | any { if (!_) { - return undefined; + return this._domain ? this._domain.slice() : undefined; } return this;