Skip to content

Commit 5c23c27

Browse files
committed
fix(counter-style): additive systems with only one symbol mapped to 0
Such systems should have range [0, 0].
1 parent ecd76fe commit 5c23c27

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/counter-style/src/CounterStyle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ const CounterStyle: Readonly<CounterStyleStatic> = Object.freeze({
122122
}
123123
});
124124
return style.withRange(
125-
values.length ? values[values.length - 1] : 0,
126-
values.length ? Infinity : -1
125+
0 in symbols ? 0 : Math.max(values.length - 1, 0),
126+
values.length ? Infinity : 0 in symbols ? 0 : -1
127127
);
128128
}
129129
});

packages/counter-style/src/__tests__/CounterStyle.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ describe('CounterStyle', () => {
106106
(CounterStyle.additive({}) as CounterStyleRendererInt).engine.specs
107107
.range
108108
).toMatchObject({ min: 0, max: -1 });
109+
expect(
110+
(CounterStyle.additive({ 0: '0' }) as CounterStyleRendererInt).engine
111+
.specs.range
112+
).toMatchObject({ min: 0, max: 0 });
109113
expect(
110114
(CounterStyle.additive({ 1: '0', 2: '1' }) as CounterStyleRendererInt)
111115
.engine.specs.range

0 commit comments

Comments
 (0)