-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add deprecation to NAME_KEY
#16710
add deprecation to NAME_KEY
#16710
Conversation
@@ -608,7 +609,7 @@ CoreObject.PrototypeMixin = Mixin.create({ | |||
let hasToStringExtension = typeof this.toStringExtension === 'function'; | |||
let extension = hasToStringExtension ? `:${this.toStringExtension()}` : ''; | |||
|
|||
let ret = `<${getName(this) || FACTORY_FOR.get(this) || this.constructor.toString()}:${guidFor( | |||
let ret = `<${ this[NAME_KEY] || getName(this) || FACTORY_FOR.get(this) || this.constructor.toString()}:${guidFor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted old behavior here, as some addon depend on it right now
@krisselden good idea ? |
IMHO, nearly all of these cases would be better implemented via a tldr; unless we are aware of actual breakage, I'd rather not bring back the lookup for |
Got it, should we at least keep deprecation ?
… On 2 Jun 2018, at 18:35, Robert Jackson ***@***.***> wrote:
IMHO, nearly all of these cases would be better implemented via a .toString on the class/mixin/etc (which would be backwards compatible). Also, most of these addons use it speculatively, and we ensured they didn't error by continuing to have an Ember.NAME_KEY present.
tldr; unless we are aware of actual breakage, I'd rather not bring back the lookup for this[NAME_KEY]...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, that seems good to me, though it will need to tell folks to use |
NAME_KEY
and expose setName
NAME_KEY
The usage of this.NAME_KEY in CoreObject instance method toString is likely never used, and the examples linked to are trying to add it to the constructor for classToString behavior. I don't remember why we did the NAME_KEY in there, I think it may have been how the factory at one point set name by passing it to create(). I'd like to redo the string stuff around just constructor.name and factory name, remove the namespace stuff. |
I see, you want to propose setName be used instead of this pattern, we use constructor to string so if they implement a toString method on the constructor, it will be used instead. |
anyway public usage should be deprecated right ? if not then you can close it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor tweak, but seems good to me after that...
packages/ember/index.js
Outdated
get() { | ||
deprecate('Using `Ember.NAME_KEY` is deprecated, override `.toString` instead', false, { | ||
id: 'ember-name-key-usage', | ||
until: '4.0.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets say 3.5.0 here, I don't think NAME_KEY
was ever public API...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, would you mind doing a deprecation-app entry for this?
['@test Ember.NAME_KEY is deprecated']() { | ||
expectDeprecation(() => { | ||
Ember.NAME_KEY; | ||
}, 'Using `Ember.NAME_KEY` is deprecated, override `.toString` instead'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should make it clear that it is static toString. MyClass.toString = () => 'MyClass'
packages/ember/index.js
Outdated
@@ -202,7 +202,20 @@ Ember.canInvoke = utils.canInvoke; | |||
Ember.tryInvoke = utils.tryInvoke; | |||
Ember.wrap = utils.wrap; | |||
Ember.uuid = utils.uuid; | |||
Ember.NAME_KEY = utils.NAME_KEY; | |||
Ember.setName = utils.setName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we prefer toString on the constructor, why are we exporting this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp. I missed this when I last reviewed. Good catch @krisselden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this and it is good to go
packages/ember/index.js
Outdated
@@ -202,7 +202,20 @@ Ember.canInvoke = utils.canInvoke; | |||
Ember.tryInvoke = utils.tryInvoke; | |||
Ember.wrap = utils.wrap; | |||
Ember.uuid = utils.uuid; | |||
Ember.NAME_KEY = utils.NAME_KEY; | |||
Ember.setName = utils.setName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this and it is good to go
c0917aa
to
914f3cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebased, and adjusted the deprecation warning to stay until v3.9.0
/cc @rwjblue
since
NAME_KEY
is still widely used https://emberobserver.com/code-search?codeQuery=NAME_KEY