Skip to content

Commit

Permalink
correctly extract dynamic path
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed May 26, 2017
1 parent 0f4a669 commit f05e97f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@
dynamicIndex = dotIndex;
}
base = value.substring(0, dynamicIndex);
dynamicPath = value.slice(-dynamicIndex);
dynamicPath = value.substring(dynamicIndex);

// Replace string references with actual references
keypath = base + dynamicPath.replace(expressionRE, function (match, reference) {
Expand Down
2 changes: 1 addition & 1 deletion dist/moon.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/directives/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ specialDirectives["m-model"] = {
dynamicIndex = dotIndex;
}
base = value.substring(0, dynamicIndex);
dynamicPath = value.slice(-dynamicIndex);
dynamicPath = value.substring(dynamicIndex);

// Replace string references with actual references
keypath = base + dynamicPath.replace(expressionRE, function(match, reference) {
Expand Down
8 changes: 8 additions & 0 deletions test/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@ describe("Directive", function() {
expect(document.getElementById('model-dynamic-msg').innerHTML).to.equal('Hello Moon!');
expect(document.getElementById('model-dynamic-msg-input').value).to.equal('Hello Moon!');
});
it('should update value of dynamic model', function() {
document.getElementById('model-dynamic-msg-input').value = "Changed";
var inputEvent = new Event('input');
document.getElementById('model-dynamic-msg-input').dispatchEvent(inputEvent);
Moon.nextTick(function() {
expect(document.getElementById('model-dynamic-msg').innerHTML).to.equal('Changed');
});
});
it('should not be present at runtime', function() {
expect(document.getElementById('model-msg-input').getAttribute("m-model")).to.be['null'];
expect(document.getElementById('model-dynamic-msg-input').getAttribute("m-model")).to.be['null'];
Expand Down

0 comments on commit f05e97f

Please sign in to comment.