Skip to content

Commit 28e6f01

Browse files
committed
Merge branch 'fix-record-clear' of github.com:zertosh/immutable-js into zertosh-fix-record-clear
Conflicts: dist/Immutable.min.js
2 parents 8cb105e + 96182d9 commit 28e6f01

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

__tests__/RecordJS.js

+15
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,19 @@ describe('Record', () => {
4949
expect(t2.soup()).toBe(204);
5050
});
5151

52+
it('can be cleared', () => {
53+
var MyType = Record({a:1, b:2, c:3});
54+
var t = new MyType({c:'cats'});
55+
56+
expect(t.c).toBe('cats');
57+
t = t.clear();
58+
expect(t.c).toBe(3);
59+
60+
var MyType2 = Record({d:4, e:5, f:6});
61+
var t2 = new MyType2({d:'dogs'});
62+
63+
expect(t2.d).toBe('dogs');
64+
t2 = t2.clear();
65+
expect(t2.d).toBe(4);
66+
});
5267
});

dist/Immutable.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3286,7 +3286,6 @@ var Record = function Record(defaultValues, name) {
32863286
} catch (error) {}
32873287
return RecordType;
32883288
};
3289-
var $Record = Record;
32903289
($traceurRuntime.createClass)(Record, {
32913290
toString: function() {
32923291
return this.__toString(this._name + ' {', '}');
@@ -3305,8 +3304,8 @@ var $Record = Record;
33053304
this._map.clear();
33063305
return this;
33073306
}
3308-
var Record = Object.getPrototypeOf(this).constructor;
3309-
return $Record._empty || ($Record._empty = makeRecord(this, Map.empty()));
3307+
var SuperRecord = Object.getPrototypeOf(this).constructor;
3308+
return SuperRecord._empty || (SuperRecord._empty = makeRecord(this, Map.empty()));
33103309
},
33113310
set: function(k, v) {
33123311
if (!this.has(k)) {

0 commit comments

Comments
 (0)