Skip to content

Commit

Permalink
Merge pull request #76 from guzart/return-state-wihout-key
Browse files Browse the repository at this point in the history
return state when using get without key
  • Loading branch information
Rich-Harris authored Dec 1, 2016
2 parents a59dc64 + a55b237 commit b3acc6d
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 b3acc6d

Please sign in to comment.