diff --git a/compiler/generate/index.js b/compiler/generate/index.js index fa2ba7816a..650be14dae 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -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 ) { diff --git a/test/compiler/get-state/_config.js b/test/compiler/get-state/_config.js new file mode 100644 index 0000000000..dd0b72fb16 --- /dev/null +++ b/test/compiler/get-state/_config.js @@ -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 }); + } +}; diff --git a/test/compiler/get-state/main.html b/test/compiler/get-state/main.html new file mode 100644 index 0000000000..c8492f4db1 --- /dev/null +++ b/test/compiler/get-state/main.html @@ -0,0 +1,12 @@ +