Skip to content

Commit

Permalink
return state when using get without key
Browse files Browse the repository at this point in the history
References #73
  • Loading branch information
guzart committed Dec 1, 2016
1 parent a59dc64 commit a55b237
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export default function generate ( parsed, source, options ) {
};
this.get = function get ( key ) {
return state[ key ];
return key ? state[ key ] : state;
};
this.set = function set ( newState ) {
Expand Down
7 changes: 7 additions & 0 deletions test/compiler/get-state/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
test ( assert, component ) {
assert.equal( component.get('a'), 1 );
assert.equal( component.get('c'), 3 );
assert.deepEqual( component.get(), { a: 1, b: 2, c: 3 });
}
};
12 changes: 12 additions & 0 deletions test/compiler/get-state/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
export default {
data: () => ({
a: 1,
b: 2
}),

computed: {
c: ( a, b ) => a + b,
}
};
</script>

0 comments on commit a55b237

Please sign in to comment.