Skip to content
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

Merged
merged 1 commit into from Dec 19, 2018

Conversation

Projects
None yet
4 participants
@bekzod
Copy link
Contributor

commented Jun 2, 2018

since NAME_KEY is still widely used https://emberobserver.com/code-search?codeQuery=NAME_KEY

@@ -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(

This comment has been minimized.

Copy link
@bekzod

bekzod Jun 2, 2018

Author Contributor

reverted old behavior here, as some addon depend on it right now

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from 01ab5d5 to 1201c55 Jun 2, 2018

@bekzod

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2018

@krisselden good idea ?

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from 1201c55 to bb17bcb Jun 2, 2018

@rwjblue

This comment has been minimized.

Copy link
Member

commented Jun 2, 2018

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]...

@bekzod

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2018

@rwjblue

This comment has been minimized.

Copy link
Member

commented Jun 2, 2018

Yes, that seems good to me, though it will need to tell folks to use .toString instead.

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from bb17bcb to 7ff3f8e Jun 2, 2018

@bekzod bekzod changed the title add deprecation to `NAME_KEY` and expose `setName` add deprecation to `NAME_KEY` Jun 2, 2018

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from 7ff3f8e to d4ac71b Jun 2, 2018

@krisselden

This comment has been minimized.

Copy link
Member

commented Jun 28, 2018

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.

@krisselden

This comment has been minimized.

Copy link
Member

commented Jun 28, 2018

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.

@bekzod

This comment has been minimized.

Copy link
Contributor Author

commented Jun 28, 2018

anyway public usage should be deprecated right ? if not then you can close it

@rwjblue
Copy link
Member

left a comment

One minor tweak, but seems good to me after that...

get() {
deprecate('Using `Ember.NAME_KEY` is deprecated, override `.toString` instead', false, {
id: 'ember-name-key-usage',
until: '4.0.0',

This comment has been minimized.

Copy link
@rwjblue

rwjblue Jun 28, 2018

Member

Lets say 3.5.0 here, I don't think NAME_KEY was ever public API...

This comment has been minimized.

Copy link
@bekzod

bekzod Jun 28, 2018

Author Contributor

done

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from d4ac71b to c4667e0 Jun 28, 2018

@rwjblue
Copy link
Member

left a comment

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');

This comment has been minimized.

Copy link
@krisselden

krisselden Jun 28, 2018

Member

should make it clear that it is static toString. MyClass.toString = () => 'MyClass'

@@ -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;

This comment has been minimized.

Copy link
@krisselden

krisselden Jun 28, 2018

Member

if we prefer toString on the constructor, why are we exporting this?

This comment has been minimized.

Copy link
@rwjblue

rwjblue Jun 28, 2018

Member

Derp. I missed this when I last reviewed. Good catch @krisselden.

This comment has been minimized.

Copy link
@krisselden

krisselden Jul 16, 2018

Member

remove this and it is good to go

@@ -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;

This comment has been minimized.

Copy link
@krisselden

krisselden Jul 16, 2018

Member

remove this and it is good to go

@bekzod bekzod force-pushed the bekzod:remove-name-key branch from c4667e0 to c0917aa Jul 17, 2018

@Turbo87 Turbo87 force-pushed the bekzod:remove-name-key branch from c0917aa to 914f3cc Dec 19, 2018

@Turbo87
Copy link
Member

left a comment

rebased, and adjusted the deprecation warning to stay until v3.9.0

/cc @rwjblue

addressed

@rwjblue rwjblue merged commit 1032b80 into emberjs:master Dec 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@bekzod bekzod deleted the bekzod:remove-name-key branch Jan 8, 2019

@efx efx referenced this pull request Feb 19, 2019

Closed

NAME_KEY is deprecated #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.