Skip to content

Commit

Permalink
Support Immutable v4rc8
Browse files Browse the repository at this point in the history
Immutable now calls toJS deeply even on immutable values contained in a
native array or object. This was broke displaying child notes, e.g. for
`Immutable.Record({bar: new Immutable.Map({a: 5}) })`.

immutable-js/immutable-js#1369
  • Loading branch information
mattzeunert committed Jan 6, 2018
1 parent f6e587f commit 5fa16d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/createFormatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export default function createFormatter(Immutable) {
}
const children = collection
.map(mapper)
.toList()
.toJS();
.toList();

const jsList = []
// Can't just call toJS because that will also call toJS on children inside the list
children.forEach(child => jsList.push(child))

return [ 'ol', listStyle, ...children ];
}

Expand Down Expand Up @@ -77,6 +81,7 @@ export default function createFormatter(Immutable) {
body(record) {
const defaults = record.clear();
const children = getKeySeq(record)
.toJS()
.map(key => {
const style = Immutable.is(defaults.get(key), record.get(key))
? defaultValueKeyStyle : alteredValueKeyStyle;
Expand All @@ -85,7 +90,7 @@ export default function createFormatter(Immutable) {
['span', style, key + ': '],
reference(record.get(key))
]
}).toJS();
});
return [ 'ol', listStyle, ...children ];
}
};
Expand Down

0 comments on commit 5fa16d4

Please sign in to comment.