Skip to content

Commit

Permalink
allow non static values
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Cornelissen committed Oct 18, 2018
1 parent 49edd88 commit aae2d26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion can-stache-converters.js
Expand Up @@ -134,7 +134,7 @@ var converters = {
}
if (args.length > 2) {
var b = args.shift();
var comparer = args.pop();
var comparer = canReflect.getValue( args.pop() );
if(b) {
for(var i = 0; i < args.length; i++) {
canReflect.setValue(args[i], comparer);
Expand Down
19 changes: 19 additions & 0 deletions test/equal_test.js
Expand Up @@ -2,6 +2,8 @@ require("can-stache-converters");
var compute = require("can-compute");
var domEvents = require("can-dom-events");
var stache = require("can-stache");
var DefineList = require("can-define/list/list");
var DefineMap = require("can-define/map/map");

var QUnit = require("steal-qunit");

Expand Down Expand Up @@ -127,3 +129,20 @@ QUnit.test("Allow multiple expressions to be passed in without ~", function() {
QUnit.equal(foo(), true, 'computed foo value is true');
QUnit.equal(bar(), true, 'computed bar value is true');
});

QUnit.test("Allow non static values", function() {
var template = stache('{{# each(foo) }}<input type="radio" checked:bind="equal(., ../bar.value)" />{{/ each}}');
var foo = new DefineList([ 'foobar' ]);
var bar = new DefineMap({value: 'zed'});

var input = template({
foo: foo,
bar: bar
}).querySelector('input');

QUnit.equal(input.checked, false, 'initially unchecked');

bar.value = 'foobar';

QUnit.equal(input.checked, true, 'now checked');
});

0 comments on commit aae2d26

Please sign in to comment.