From 5ebd43898cf0a996c8061a25974c2f00dcce2feb Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 17:56:29 -0400 Subject: [PATCH] deprecate get with string argument --- src/shared/index.js | 7 ++++++- .../dev-warning-missing-data-computed/_actual-bundle-v2.js | 7 ++++++- .../expected-bundle-v2.js | 7 ++++++- .../dev-warning-missing-data-computed/expected-bundle.js | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/shared/index.js b/src/shared/index.js index 3ff0a2d421c3..5ec905d29bd8 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -51,6 +51,11 @@ export function fire(eventName, data) { } } +export function getDev(key) { + if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); + return get.call(this, key); +} + export function get(key) { return key ? this._state[key] : this._state; } @@ -204,7 +209,7 @@ export var proto = { export var protoDev = { destroy: destroyDev, - get: get, + get: getDev, fire: fire, observe: observeDev, on: onDev, diff --git a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js index 90ed9b52581e..69a58fa93330 100644 --- a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js @@ -66,6 +66,11 @@ function fire(eventName, data) { } } +function getDev(key) { + if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); + return get.call(this, key); +} + function get(key) { return key ? this._state[key] : this._state; } @@ -188,7 +193,7 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: get, + get: getDev, fire: fire, observe: observeDev, on: onDev, diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js index 90ed9b52581e..69a58fa93330 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js @@ -66,6 +66,11 @@ function fire(eventName, data) { } } +function getDev(key) { + if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); + return get.call(this, key); +} + function get(key) { return key ? this._state[key] : this._state; } @@ -188,7 +193,7 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: get, + get: getDev, fire: fire, observe: observeDev, on: onDev, diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index b580ce115577..caaf43221f89 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -66,6 +66,11 @@ function fire(eventName, data) { } } +function getDev(key) { + if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); + return get.call(this, key); +} + function get(key) { return key ? this._state[key] : this._state; } @@ -188,7 +193,7 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: get, + get: getDev, fire: fire, observe: observeDev, on: onDev,