New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dots in Observe keys #318

Merged
merged 2 commits into from Mar 16, 2013

Conversation

Projects
None yet
2 participants
@daffl
Contributor

daffl commented Mar 15, 2013

I already merged this fix into the 1.2 develop branch with #309 but suggest to make this part of the 1.1.5 release as well. All tests are still passing and it doesn't introduce a new API. The fix makes this possible:

var ob = new can.Observe();

ob.attr('a.b', 'test');
ob.attr() // -> { a: { b: 'test' } }

ob.attr({
    'a.b': 'test'
});

ob.attr() // -> { 'a.b': 'test' }

ob.attr('a.b')
// will look for 'a.b' first
// and then for ob.attr('a').attr('b')

Since new Observe({ 'test.key': 'value' }) failed before, introducing the direct key lookup for obsreve.attr('test.key') (and falling back to the nested property lookup if it doesnt' exist) shouldn't pose a problem for any existing functionality. Fixes #257 and #296.

daffl added a commit that referenced this pull request Mar 16, 2013

@daffl daffl merged commit 7b869db into master Mar 16, 2013

1 check passed

default The Travis build passed
Details

@daffl daffl deleted the observe-dot-key-257-296 branch Mar 16, 2013

@schovi

This comment has been minimized.

Show comment
Hide comment
@schovi

schovi Mar 27, 2013

Contributor

Having issue with set dotted key

Your example

var ob = new can.Observe();

ob.attr('a.b', 'test');
ob.attr() // -> { a: { b: 'test' } }

Throw me classic old error "can.Observe: Object does not exist"

http://jsfiddle.net/schovi/zTF9s/

Read works fine

Contributor

schovi commented Mar 27, 2013

Having issue with set dotted key

Your example

var ob = new can.Observe();

ob.attr('a.b', 'test');
ob.attr() // -> { a: { b: 'test' } }

Throw me classic old error "can.Observe: Object does not exist"

http://jsfiddle.net/schovi/zTF9s/

Read works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment