Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Use standard event.preventDefault when available (event.returnValue is deprecated) #4557

Closed
jasford opened this issue Oct 21, 2013 · 24 comments

Comments

@jasford
Copy link

jasford commented Oct 21, 2013

I'm getting this warning from Chrome:

event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

Pointing to these lines of angular.js:

event.isDefaultPrevented = function() {
  return event.defaultPrevented || event.returnValue == false;
}

This is a deprecation warning. Everything still works just fine, but it seems like the issue should be addressed by AngularJS. I'm still new enough to AngularJS that I don't feel comfortable putting together a pull request myself.

Note that my Chrome version is 31.0.1650.26 beta


EDIT: This is not a jQuery issue. I'm providing links to the jQuery tickets below for reference since the issue is similar. I am not using jQuery at all, so simply upgrading jQuery will not resolve the issue.


For reference, these jQuery tickets looks very similar. The first one, flagged as a duplicate of the second, shows the exact same Chrome warning message I'm seeing. The second one shows the fix jQuery made to begin using the standard event.preventDefault:

@caitp
Copy link
Contributor

caitp commented Oct 21, 2013

IIRC, IE9 still listens to returnValue and not defaultPrevented -- an issue about this came up recently, I'll see if I can find it. Hmm, may have been on IRC. But yeah, I believe IE9 (a supported browser) is still affected. If not, cool.

@doron2402
Copy link

I believe the issue is in Jquery and not in the Ember/Backbone/Angular.
I will keep you update when I'll find a solution

@ghost
Copy link

ghost commented Nov 14, 2013

@caitp IE9 seems to support event.preventDefault http://msdn.microsoft.com/en-us/library/ff975460%28VS.85%29.aspx

@Pickra
Copy link

Pickra commented Nov 14, 2013

This is definitely a JQuery issue. I'm not using Angular and also received this message.

@jasford
Copy link
Author

jasford commented Nov 14, 2013

Yes – it is an issue in the jQuery library, which has been fixed in the tickets listed above. The problem is that it is also an issue in jqLight, which is packaged with Angular, and needs to be fixed there as well.

@drozzy
Copy link

drozzy commented Nov 20, 2013

Have the same problem - really annoying :-)

@shamganikapudi
Copy link

Me too

@shamganikapudi
Copy link

try using the latest jquery file

http://code.jquery.com/jquery-git.js

@cherrypophead
Copy link

I'm using bootstrap3 and am getting this warning,

@reyrodrigez
Copy link

That's jquery issue raised as a bug:
http://bugs.jquery.com/ticket/14320

@dvorpahl
Copy link

dvorpahl commented Dec 2, 2013

same console notice when receiving Chromes internal Page for "Error 502" - this seems to be a generally problem to use this js property marked as "deprecated".

@jasford
Copy link
Author

jasford commented Dec 3, 2013

try using the latest jquery file

I'm not using jQuery at all. The warning seems to be coming from jqLight. I opened this issue because it appears that jQuery has made some changes to resolve the issue and that similar changes need to be made to jqLight.

@trollglodita
Copy link

I'm NOT using jQuery, just Google Maps API and Javascript and I'm getting this: "Please use the standard event.preventDefault() instead.".

Any clue?

@evanplaice
Copy link

@jasford Ditto. I'm trying out angular without jquery and I'm getting the same error.

According to this StackOverflow question the issue has been fixed in the jQuery source as of v1.11. I think it's just a matter of updating the jqLite source in angular.js.

Note: I'm using the Angular.js 1.2.4 source from apis.google.com.

Here are my includes:

  • <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js"></script>
  • <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular-route.js"></script>

@doron2402
Copy link

All, just use the newest version of jquery it will fix it.

@ahoereth
Copy link

I am not using jQuery. Warning occurs in angular.js:2605 - 1.2.7
+1 to jasford

@doron2402
Copy link

can u upload example code? I can't get the error

@mediastuttgart
Copy link

still occurs with v1.2.10-build.2163+sha.6c9131e - comes from JQLite inside angular as mentioned above.

@jasford
Copy link
Author

jasford commented Feb 4, 2014

@doron2402: All, just use the newest version of jquery it will fix it.

I just edited the issue description above to make it even more clear that this is not an issue with jQuery – upgrading jQuery will not resolve the issue since, like @ahoereth and others above, I am not using jQuery at all.

@lookfirst
Copy link

@jasford is totally correct. would be nice to see a fix for this. 4 months is a long time.

@caitp
Copy link
Contributor

caitp commented Feb 5, 2014

@lookfirst have you (or anyone else) contributed a fix for this? I'm looking through the PRs but I'm not sure if anyone has yet.

lookfirst added a commit to lookfirst/angular.js that referenced this issue Feb 5, 2014
@tbosch tbosch self-assigned this Feb 6, 2014
@tbosch tbosch added this to the Backlog milestone Feb 6, 2014
@tbosch tbosch removed their assignment Feb 6, 2014
@diwa-zz
Copy link

diwa-zz commented Apr 16, 2014

Would be good to get rid of this pesky warning.

@mgol
Copy link
Member

mgol commented Aug 1, 2014

This is a relevant jQuery commit: jquery/jquery@4671ef1

If anyone is interested in having it working with jqLite, pull request welcome!

(note that this is just a warning, everything works fine)

@btford btford removed the gh: issue label Aug 20, 2014
shwei added a commit to shwei/angular.js that referenced this issue Nov 22, 2014
shwei added a commit to shwei/angular.js that referenced this issue Nov 22, 2014
shwei added a commit to shwei/angular.js that referenced this issue Nov 22, 2014
rkirov pushed a commit that referenced this issue Nov 22, 2014
…ent.returnValue. Related to issue #4557. Worked with @bullwrinkle on this.
@rkirov
Copy link
Contributor

rkirov commented Nov 22, 2014

#10181 took care of the last returnValue reference in our codebase, and I don't see the warning any longer.

@rkirov rkirov closed this as completed Nov 22, 2014
rkirov pushed a commit that referenced this issue Nov 22, 2014
…ent.returnValue. Related to issue #4557. Worked with @bullwrinkle on this.
@IgorMinar IgorMinar modified the milestones: ng-fixit #1, Backlog Nov 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests