Skip to content

Commit 561d6a2

Browse files
committed
fix error with accessing undefined array
1 parent bd70c48 commit 561d6a2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

dist/component/CharacterMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ var CharacterMap = function (_React$Component) {
188188
* that character from secondary and replace the least used character
189189
* from primary with it.
190190
*/
191-
if (this.secondaryPaletteCache[0].count > this.paletteCache[paletteMaxSize - 1].count) {
191+
if (this.paletteCache[paletteMaxSize - 1] && this.secondaryPaletteCache[0].count > this.paletteCache[paletteMaxSize - 1].count) {
192192
var maxCountCharInSecondaryPalette = this.secondaryPaletteCache.shift();
193193
this.paletteCache[paletteMaxSize - 1] = maxCountCharInSecondaryPalette;
194194
this.paletteCache.sort(function (a, b) {

src/component/CharacterMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class CharacterMap extends React.Component {
129129
* that character from secondary and replace the least used character
130130
* from primary with it.
131131
*/
132-
if (this.secondaryPaletteCache[0].count > this.paletteCache[paletteMaxSize - 1].count) {
132+
if (this.paletteCache[paletteMaxSize - 1] && this.secondaryPaletteCache[0].count > this.paletteCache[paletteMaxSize - 1].count) {
133133
const maxCountCharInSecondaryPalette = this.secondaryPaletteCache.shift();
134134
this.paletteCache[paletteMaxSize - 1] = maxCountCharInSecondaryPalette;
135135
this.paletteCache.sort( ( a, b ) => b.count - a.count );

0 commit comments

Comments
 (0)