diff --git a/src/model/ModelBase.js b/src/model/ModelBase.js index 6555a3cf44..fe699e253c 100755 --- a/src/model/ModelBase.js +++ b/src/model/ModelBase.js @@ -82,7 +82,7 @@ export default class ModelBase { children.push(this.joinKey(i)); }); } else if (isObject(value) || isFunction(value)) { - children = objectKeys(value).map(key => this.joinKey(key)); + children = objectKeys(value).map(key => this.joinKey(escapeKey(key))); } else if (value != null) { children = []; } diff --git a/tests/browser/methods/observe.js b/tests/browser/methods/observe.js index 1b2f0cc4cf..bede0f1f87 100644 --- a/tests/browser/methods/observe.js +++ b/tests/browser/methods/observe.js @@ -621,6 +621,26 @@ export default function() { ractive.set('gup.foo.bar', { baz: 2 }); }); + test('An observed wildcard can be an escaped string (#3319)', t => { + t.expect(4); + + const ractive = new Ractive({ + el: fixture, + template: 'blah', + data: { gup: { 'foo.bar': { baz: 1 } } } + }); + + let expected = 1; + + ractive.observe('gup.*.baz', (n, o, keypath) => { + t.deepEqual(n, expected); + t.equal(keypath, 'gup.foo\\.bar.baz'); + }); + + expected = 2; + ractive.set('gup.foo\\.bar', { baz: 2 }); + }); + test('Pattern observers fire when ractive.update() is called without parameters', t => { t.expect(2);