You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jquery-integration optional feature prints a warning even when enabled #16849
I've followed all the steps that are needed for enabling jQuery integration (I have the latest versions of @ember/jquery and @ember/optional-features installed and in package.json; have "jquery-integration": true in optional-features.json) but I still see a warning in the console when accessing originalEvent. I see the following check:
I think _JQUERY_INTEGRATION defaults to true and perhaps it is being removed from the hash because it has the same value? If this is so, the code above should be changed to:
@boris-petrov so you have a optional-features.json file with 'jquery-integration': true and you still see a warning? Can you make an example app that reproduces the issue and link here?
@pixelhandler - now that I think about it, this warning comes from a third-party plugin - namely ember-drag-drop. There is actually an issue opened there. But in any case - I do have optional-features.json with 'jquery-integration': true, yes. It doesn't warn me when I use originalEvent in my code but it doesn't suppress the issue in plugins. Is that expected and is there something I can do (apart from waiting for the addon to be updated)?
@boris-petrovEmberENV._JQUERY_INTEGRATION !== false would also trigger the deprecation when the user explicitly opted into having jQuery (by setting the jquery-integration to true), which we want to prevent, in accordance to the RFC. If he explicitly wants to use jQuery, he should be able to do so, including using originalEvent and that without any deprecations.
@simonihmig - the documentation for deprecate specifies that only falsy values would trigger the deprecation. _JQUERY_INTEGRATION being either true or undefined would result in EmberENV._JQUERY_INTEGRATION !== false to be true (as both are not equal to false) which will not trigger the assertion. Only a value of false for EmberENV._JQUERY_INTEGRATION would result in this expression to be false and hence show the deprecation. Or am I missing something?
_JQUERY_INTEGRATION being either true or undefined would result in EmberENV._JQUERY_INTEGRATION !== false to be true (as both are not equal to false) which will not trigger the assertion.
But we want to show the deprecation if the flag is undefined, and only then!
We don't show it when it's either true (user explicitly wants jQuery) or false (their is no jQuery available in the first place, so any use of $, .originalEvent or whatever else comes from jQuery would break the code anyway).
But because of the mentioned behavior in ember-optional-features we have no way to distinguish at runtime if the user did not set it (it's undefined), or he/she explicitly set it to true.
Activity
pixelhandler commentedon Aug 25, 2018
@boris-petrov so you have a
optional-features.jsonfile with'jquery-integration': trueand you still see a warning? Can you make an example app that reproduces the issue and link here?boris-petrov commentedon Aug 28, 2018
@pixelhandler - now that I think about it, this warning comes from a third-party plugin - namely
ember-drag-drop. There is actually an issue opened there. But in any case - I do haveoptional-features.jsonwith'jquery-integration': true, yes. It doesn't warn me when I useoriginalEventin my code but it doesn't suppress the issue in plugins. Is that expected and is there something I can do (apart from waiting for the addon to be updated)?boris-petrov commentedon Aug 29, 2018
Actually, I lied. This also warns in our own code. I have something like:
And this gives the warning. Please tell me if you cannot reproduce it with this code and I will try to create a full sample.
simonihmig commentedon Aug 29, 2018
I can confirm things behave strangely here. Will investigate...
simonihmig commentedon Aug 29, 2018
Exactly: https://github.com/emberjs/ember-optional-features/blob/master/index.js#L75-L78
This basically makes it impossible to distinguish between jQuery being enabled by default and enabled explicitly. But we rely on this distinction here:
https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/system/jquery_event_deprecation.js#L24-L31
I would say we should fix this in
ember-optional-features. I can create a PR if we agree. @rwjblue your thoughts?boris-petrov commentedon Aug 29, 2018
@simonihmig - why do you prefer to fix this in
ember-optional-featuresand not what I've suggested in the original post? I think this would also work.simonihmig commentedon Aug 29, 2018
@boris-petrov
EmberENV._JQUERY_INTEGRATION !== falsewould also trigger the deprecation when the user explicitly opted into having jQuery (by setting thejquery-integrationto true), which we want to prevent, in accordance to the RFC. If he explicitly wants to use jQuery, he should be able to do so, including usingoriginalEventand that without any deprecations.boris-petrov commentedon Aug 29, 2018
@simonihmig - the documentation for deprecate specifies that only falsy values would trigger the deprecation.
_JQUERY_INTEGRATIONbeing eithertrueorundefinedwould result inEmberENV._JQUERY_INTEGRATION !== falseto betrue(as both are not equal tofalse) which will not trigger the assertion. Only a value offalseforEmberENV._JQUERY_INTEGRATIONwould result in this expression to befalseand hence show the deprecation. Or am I missing something?simonihmig commentedon Aug 29, 2018
But we want to show the deprecation if the flag is undefined, and only then!
We don't show it when it's either true (user explicitly wants jQuery) or false (their is no jQuery available in the first place, so any use of
$,.originalEventor whatever else comes from jQuery would break the code anyway).But because of the mentioned behavior in
ember-optional-featureswe have no way to distinguish at runtime if the user did not set it (it's undefined), or he/she explicitly set it to true.bendemboski commentedon Sep 13, 2018
FWIW, here's a repo with a failing test for the issue.
Do not populate EmberENV with default values
simonihmig commentedon Sep 14, 2018
@bendemboski Thanks for the reproduction, that was helpful!
I created a PR for
ember-optional-featuresthat fixes the problem: emberjs/ember-optional-features#24Do not populate EmberENV with default values