8000 Ensure when OrderedSet becomes empty, that it remains OrderedSet (#1335) · lisongyu/immutable-js@ff8094f · GitHub
[go: up one dir, main page]

Skip to content

Commit ff8094f

Browse files
authored
Ensure when OrderedSet becomes empty, that it remains OrderedSet (immutable-js#1335)
Fixes immutable-js#1188
1 parent b9dabc1 commit ff8094f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

__tests__/issues.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
///<reference path='../resources/jest.d.ts'/>
99

1010
declare var Symbol: any;
11-
import { List, OrderedMap, Record, Seq, Set } from '../';
11+
import { List, OrderedMap, OrderedSet, Record, Seq, Set } from '../';
1212

1313
describe('Issue #1175', () => {
1414
it('invalid hashCode() response should not infinitly recurse', () => {
@@ -26,6 +26,14 @@ describe('Issue #1175', () => {
2626
});
2727
});
2828

29+
describe('Issue #1188', () => {
30+
it('Removing items from OrderedSet should return OrderedSet', () => {
31+
const orderedSet = OrderedSet(['one', 'two', 'three']);
32+
const emptyOrderedSet = orderedSet.subtract(['two', 'three', 'one']);
33+
expect(OrderedSet.isOrderedSet(emptyOrderedSet)).toBe(true);
34+
});
35+
});
36+
2937
describe('Issue #1220 : Seq.rest() throws an exception when invoked on a single item sequence ', () => {
3038
it('should be iterable', () => {
3139
// Helper for this test

src/Set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class Set extends SetCollection {
164164
const newMap = this._map.__ensureOwner(ownerID);
165165
if (!ownerID) {
166166
if (this.size === 0) {
167-
return emptySet();
167+
return this.__empty();
168168
}
169169
this.__ownerID = ownerID;
170170
this._map = newMap;

0 commit comments

Comments
 (0)
0