Skip to content

Commit

Permalink
Fixing the issue where byNumber[slideNumber] was undefined, yet we we…
Browse files Browse the repository at this point in the history
…re still calling .push on it
  • Loading branch information
peterj committed Jan 27, 2020
1 parent 637be99 commit b3b05ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/remark/models/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ function createSlides (slideshowSource, options) {
} else {
if (slideIsIncluded) {
slides.push(slideViewModel);
slides.byNumber[slideNumber].push(slideViewModel);
if (slides.byNumber[slideNumber] !== undefined) {
slides.byNumber[slideNumber].push(slideViewModel);
}
}
if (slide.properties.name) {
slides.byName[slide.properties.name] = slideViewModel;
Expand Down
8 changes: 8 additions & 0 deletions test/remark/models/slideshow_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ describe('Slideshow', function () {
});
});

describe('non-countable slides', function() {
it('should not be counted if set on first slide', function() {
slideshow.loadFromString('count: false\n\na\n---\nb');
slideshow.getSlides().length.should.equal(2);
slideshow.getSlidesByNumber(1)[0].getSlideNumber().should.equal(1);
});
});

describe('name mapping', function () {
it('should map named slide', function () {
slideshow.loadFromString('name: a\n---\nno name\n---\nname: b');
Expand Down

0 comments on commit b3b05ff

Please sign in to comment.