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

Commit

Permalink
protect against undefined context in Member.valueFn
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed Jan 14, 2014
1 parent b9bead5 commit db4a055
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/polymer-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@
if (path) {
if (observer)
observer.addPath(context, path);
return context[property.name];
return path.getValueFrom(context);
}

var propName = property(model, observer);
if (observer)
observer.addPath(context, propName);
return context[propName];
return context ? context[propName] : undefined;
};
}
return this.valueFn_;
Expand Down
18 changes: 18 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,24 @@ suite('PolymerExpressions', function() {
});
});

// https://github.com/Polymer/polymer-expressions/issues/19
test('issue-19', function(done) {
var div = createTestHtml(
'<template id="t" bind="{{ foo.bar as b }}">' +
'<span>{{ b }}</span>' +
'</template>');

var model = {};

recursivelySetTemplateModel(div, model);

then(function() {
var target = div.childNodes[1];

done();
});
});

test('Non-model path expressions', function() {
assert.isFalse(getExpression_('a + b').nonModelPath);
assert.isFalse(getExpression_('a + b > 3 + hello["kitty"]').nonModelPath);
Expand Down

0 comments on commit db4a055

Please sign in to comment.