Skip to content

Commit

Permalink
add test for object section updates ractivejs#1476
Browse files Browse the repository at this point in the history
  • Loading branch information
evs-chris committed Nov 13, 2014
1 parent 52318ca commit 55d990b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/modules/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,32 @@ define([ 'ractive', 'samples/render' ], function ( Ractive, tests ) {
t.htmlEqual( fixture.innerHTML, '<div id="foo">foo</div>' );
});

test( 'Value changes in object iteration should cause updates (#1476)', t => {
var ractive = new Ractive({
el: fixture,
template: '{{#obj[sel]:sk}}{{sk}} {{@key}} {{.}}{{/}}',
data: {
obj: {
key1: { a: 'a1', b: 'b1' },
key2: { a: 'a2', b: 'b2', c: 'c2' },
key3: { c: 'c3' }
},
sel: 'key1'
}
});

t.htmlEqual( fixture.innerHTML, 'a a a1b b b1' );

ractive.set( 'sel', 'key2' );
t.htmlEqual( fixture.innerHTML, 'a a a2b b b2c c c2' );

ractive.set( 'sel', 'key3' );
t.htmlEqual( fixture.innerHTML, 'c c c3' );

ractive.set( 'sel', 'key1' );
t.htmlEqual( fixture.innerHTML, 'a a a1b b b1' );
});

};

function deepClone ( source ) {
Expand Down

0 comments on commit 55d990b

Please sign in to comment.