diff --git a/compiler/generate/index.js b/compiler/generate/index.js index fa2ba7816a27..650be14dae65 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 000000000000..dd0b72fb16af --- /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 000000000000..c8492f4db1ef --- /dev/null +++ b/test/compiler/get-state/main.html @@ -0,0 +1,12 @@ +