Skip to content

Commit

Permalink
Fix _patchMatchesEffect. (#3631)
Browse files Browse the repository at this point in the history
Listening for `foo.bar.*` does not trigger for `foo.bars`.
  • Loading branch information
kaste authored and dfreedm committed Jun 20, 2016
1 parent 1058896 commit b78e5af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/standard/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
var effectArg = effect.trigger.name;
return (effectArg == path) ||
(effectArg.indexOf(path + '.') === 0) ||
(effect.trigger.wildcard && path.indexOf(effectArg) === 0);
(effect.trigger.wildcard && path.indexOf(effectArg + '.') === 0);
},

/**
Expand Down
32 changes: 32 additions & 0 deletions test/unit/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,38 @@
arraysEqual(el.array, [-1, 99, 2, 3]);
});

test('patch matches effect', function() {
var effect = {
trigger: {
name: 'foo.bar'
}
};

assert.isTrue(el._pathMatchesEffect('foo', effect));
assert.isTrue(el._pathMatchesEffect('foo.bar', effect));

assert.notOk(el._pathMatchesEffect('bar', effect));
assert.notOk(el._pathMatchesEffect('foobar', effect));
assert.notOk(el._pathMatchesEffect('foo.bar.baz', effect));
assert.notOk(el._pathMatchesEffect('foo.baz', effect));

effect = {
trigger: {
name: 'foo.bar',
wildcard: true
}
};

assert.isTrue(el._pathMatchesEffect('foo', effect));
assert.isTrue(el._pathMatchesEffect('foo.bar', effect));
assert.isTrue(el._pathMatchesEffect('foo.bar.baz', effect));

assert.notOk(el._pathMatchesEffect('foobar', effect));
assert.notOk(el._pathMatchesEffect('foo.bars', effect));
assert.notOk(el._pathMatchesEffect('foo.baz', effect));

});

});

suite('malformed observers', function() {
Expand Down

0 comments on commit b78e5af

Please sign in to comment.