Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Empty item templates produces holes in collection #408

Open
kpdecker opened this issue Jan 8, 2015 · 2 comments
Open

Empty item templates produces holes in collection #408

kpdecker opened this issue Jan 8, 2015 · 2 comments
Labels
Milestone

Comments

@kpdecker
Copy link
Contributor

kpdecker commented Jan 8, 2015

This can lead to future rendering failures when an inserted item's sibling can not be found.

  it('should work with empty elements', function() {
    var view = new Thorax.View({
      template: Handlebars.compile("{{#collection}}\n{{#if render}}\n{{letter}}\n{{/if}}\n{{/collection}}"),
      collection: new Thorax.Collection([
        {letter: 'a', render: false},
        {letter: 'b', render: true},
        {letter: 'c', render: false},
        {letter: 'd', render: true},
        {letter: 'e', render: true}
      ])
    });
    view.render();
    expect(view.$el.text()).to.equal('bde');
    expect(view.$('[data-model-cid]').length).to.equal(5);
  });
@kpdecker kpdecker added the bug label Jan 8, 2015
@kpdecker kpdecker added this to the 3.0 milestone Jan 8, 2015
@kpdecker
Copy link
Contributor Author

kpdecker commented Jan 8, 2015

Under Handlebars 2.x this will fail with the following failure:

  1) collection should work with empty elements:
     Error: expected 3 to equal 5
      at Assertion.assert (thorax/node_modules/expect.js/index.js:96:13)
      at Assertion.be.Assertion.equal (thorax/node_modules/expect.js/index.js:216:10)
      at Context.<anonymous> (thorax/build/dev/test-fruit-loops-server.js:243:50)
      at Test.Runnable.run (thorax/node_modules/mocha/lib/runnable.js:221:32)
      at Runner.runTest (thorax/node_modules/mocha/lib/runner.js:374:10)
      at thorax/node_modules/mocha/lib/runner.js:452:12
      at next (thorax/node_modules/mocha/lib/runner.js:299:14)
      at thorax/node_modules/mocha/lib/runner.js:309:7
      at next (thorax/node_modules/mocha/lib/runner.js:247:23)
      at Object._onImmediate (thorax/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:345:15)

@kpdecker
Copy link
Contributor Author

kpdecker commented Jan 8, 2015

cf8f488 masks this failure slightly due to the append only mode operation but we should output placeholder elements for empty content items so independent inserts will have the proper placeholders.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant