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

[BUGFIX beta] Adds a deprecation message when using targetObject #14590

Merged
merged 1 commit into from
Nov 5, 2017

Conversation

sduquej
Copy link
Contributor

@sduquej sduquej commented Nov 8, 2016

For #14168

@rwjblue is this enough or should we also assert when setting targetObject? If so, where might I add that check?

@rwjblue
Copy link
Member

rwjblue commented Nov 8, 2016

This is good for the specifying of a targetObject, but we also need to deprecate folks asking for it (i.e. this.get('targetObject')).

The thought was that we would need to use an actual JS getter with a deprecation for that. Something like:

import { descriptor }  from 'ember-metal';

// ...snip...

 targetObject: descriptor({
    get() {
      deprecate('good message', false, { until: '2.12.0', url: 'some-path', id: 'ember-views.targetObject' });
      return this._targetObject;
    },

    set(value) {
      deprecate('good message', false, { until: '2.12.0', url: 'some-path', id: 'ember-views.targetObject' });
      return this._targetObject = value;
    }
  })

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch from 7069fb9 to dd9f51a Compare November 9, 2016 00:34
@sduquej
Copy link
Contributor Author

sduquej commented Nov 9, 2016

Thanks, @rwjblue. That was really helpful.

@sduquej sduquej changed the title [WIP] [BUGFIX beta] Adds a deprecation message when using [WIP] [BUGFIX beta] Adds a deprecation message when using targetObject Nov 9, 2016
@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch from dd9f51a to ce83c99 Compare November 16, 2016 19:49
@pixelhandler
Copy link
Contributor

@sduquej Can you add the code (provided by @rwjblue) to define targetObject as deprecated via set/set to the mixin as well ?

@sduquej
Copy link
Contributor Author

sduquej commented Nov 19, 2016

Tried that @pixelhandler, but then ran into tests failing as classes that include the Ember.TargetActionSupport mixin would now have a targetObject property (the descriptor).

There's a few places where the framework iterates over all properties in an object so targetObject would come up raising the deprecation warning, for example here: https://github.com/emberjs/ember.js/blob/master/packages/ember-runtime/lib/inject.js#L56

It didn't feel right to add special-case handling in these places as they were a consequence of adding the code to the mixin which is why we came up with the init approach.

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch from ce83c99 to a2930ef Compare November 19, 2016 11:27
@sduquej sduquej changed the title [WIP] [BUGFIX beta] Adds a deprecation message when using targetObject [BUGFIX beta] Adds a deprecation message when using targetObject Nov 19, 2016
@rwjblue
Copy link
Member

rwjblue commented Nov 19, 2016

Ya, we have to make it non-enumerable (which will cause it to not show up in list of keys).

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch 5 times, most recently from 32017e5 to 65a57f1 Compare November 19, 2016 21:07
@sduquej
Copy link
Contributor Author

sduquej commented Nov 19, 2016

I totally missed that option 😅. Have rebased and udpated the PR accordingly.

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch 2 times, most recently from a22a251 to c279d9e Compare November 20, 2016 10:00
@sduquej
Copy link
Contributor Author

sduquej commented Nov 20, 2016

What's the best way to silence deprecations within the framework itself?
I read https://github.com/emberjs/rfcs/blob/master/text/0065-deprecation-warning-handlers.md
but found no usages outside of ember-debug.

The build is currently failing in the production suite because I want to silence deprecations here:
https://github.com/emberjs/ember.js/pull/14590/files#diff-eba568646bdc7cb8b35def52b7e49e9cR173

@MiguelMadero
Copy link
Contributor

MiguelMadero commented Nov 21, 2016

Is the idea to use target instead?

In Ember 2.7 we used to be able to read and set targetObject. It's gone in 2.9, but using _targetObject worked. While both are private they worked. By reading this, if I understood correctly the idea is to use target instead, but that didn't work in the way I was using it on adopted-ember-addons/ember-cli-hot-loader#34

We have inside a component wrapper something like:

{{#component wrappedComponentName _targetObject=_targetObject 

I understand based on the deprecation warning that we were supposed to use target instead, however that didn't work either

{{#component wrappedComponentName target=target 

What worked across versions was, but that's supposed to be deprecated is reading from _targetObject and setting targetObject:

{{#component wrappedComponentName targetObject=_targetObject 

@chancancode chancancode added this to the 2.12.0 milestone Dec 11, 2016
@rwjblue rwjblue modified the milestones: 2.12.0, 2.14.0 Apr 29, 2017
@@ -159,5 +165,23 @@ function getTarget(instance) {
}
}

registerHandler(function(message, options, next) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this line and the line below that does target = get(instance, 'targetObject') (so that we don't trigger the deprecation).

Things should fall through now that we have the getter/setter above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Updated

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch 2 times, most recently from 6e9d228 to c5eae9d Compare August 19, 2017 13:55

function _deprecateTargetObject() {
let message = 'Usage of `targetObject` is deprecated. Please use `target` instead.';
let options = { id: 'ember-runtime.using-targetObject', until: '2.15.0' };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to 2.15.0. Perhaps we'd like it to be a later version, if so which?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, it will need to be 2.17.0 at this point.

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch from c5eae9d to 4090175 Compare August 19, 2017 23:18
@sduquej
Copy link
Contributor Author

sduquej commented Aug 20, 2017

@rwjblue Thanks! Updated.

@GavinJoyce
Copy link
Member

GavinJoyce commented Oct 30, 2017

@rwjblue it would be good to get this merged. As it's been ~6 weeks since the deprecation target was set to 2.17.0, perhaps it now needs to be 2.18.0?

configurable: true,
enumerable: false,
get() {
_deprecateTargetObject();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I think we actually want to duplicate the code for this helper method so that it can properly be stripped from production builds.

Can you move the code into both the get and set directly?

return null;
}

function _deprecateTargetObject() {
let message = 'Usage of `targetObject` is deprecated. Please use `target` instead.';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should pass a bit more debugging info here. If I saw this message in the console, I'm not sure how I would track down where it was coming from. Perhaps you can include this (which will display something like <component:foo-bar#1234> which might give someone a clue...).


function _deprecateTargetObject() {
let message = 'Usage of `targetObject` is deprecated. Please use `target` instead.';
let options = { id: 'ember-runtime.using-targetObject', until: '2.17.0' };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've let this slip yet again, and I am very sorry. Can you update this again to 3.5.0?

@sduquej sduquej force-pushed the sd/deprecate-usage-of-targetObject branch from 4090175 to 24a32b1 Compare November 5, 2017 10:52
@sduquej
Copy link
Contributor Author

sduquej commented Nov 5, 2017

@rwjblue Updated! 🙇

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your patience and hard work here. Sorry for all the delays, great work! 👏👏🎉

@rwjblue rwjblue merged commit 8109f90 into emberjs:master Nov 5, 2017
@sduquej sduquej deleted the sd/deprecate-usage-of-targetObject branch November 5, 2017 12:39
@sduquej
Copy link
Contributor Author

sduquej commented Nov 5, 2017

🍻 @rwjblue No problem at all! Perhaps you'd like to close the original issue (#14168) now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants