From a55b2374ae73c9619e8beff0f871448a29ab413d Mon Sep 17 00:00:00 2001 From: Arturo Guzman Date: Wed, 30 Nov 2016 21:28:05 -0500 Subject: [PATCH] return state when using get without key References #73 --- compiler/generate/index.js | 2 +- test/compiler/get-state/_config.js | 7 +++++++ test/compiler/get-state/main.html | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/compiler/get-state/_config.js create mode 100644 test/compiler/get-state/main.html 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 @@ +