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

jQuery migrate 3.0.1 shows warnings with angularjs 1.7.6-1.7.8 for removeAttr #16877

Closed
3 tasks
git-ram-pal opened this issue May 27, 2019 · 4 comments
Closed
3 tasks

Comments

@git-ram-pal
Copy link

AngularJS is in LTS mode

We are no longer accepting changes that are not critical bug fixes into this project.
See https://blog.angular.io/stable-angularjs-and-long-term-support-7e077635ee9c for more detail.

I'm submitting a ...

  • regression from 1.7.0
  • security issue
  • issue caused by a new browser version
  • [ X] other

Current behavior:

jQuery migrate 3.0.1 shows warnings as "JQMIGRATE: jQuery.fn.removeAttr no longer sets boolean properties: disabled" with angular 1.7.6 to 1.7.8.

Expected / new behavior:

As per jQuery migrate documentation removeAttr should not be used. Instead .prop( "checked", false ) should be used.
https://github.com/jquery/jquery-migrate/blob/master/warnings.md

Minimal reproduction of the problem with instructions:

AngularJS version: 1.7.x

Yes this issue occurs with most recent version of angularjs 1.7.8.

Browser: [all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView | Opera XX ]

Anything else:

Instead of using .removeAttr("checked") we can use .prop("checked", false)

@git-ram-pal
Copy link
Author

This issue is related to the change
#16779

@git-ram-pal
Copy link
Author

@git-ram-pal
Copy link
Author

This issue only occurs if we include jQuery migrate in our application.
Closing the ticket as application works fine if we remove jQuery migrate.

@mgol
Copy link
Member

mgol commented Jun 5, 2019

@git-ram-pal Thanks for the report. While you closed it, I still wanted to provide some details here:

  1. AngularJS doesn't support jQuery with Migrate. While it may work in many cases, it's not something that we actively test.
  2. jQuery itself doesn't produce any warnings; Migrate does when it encounters usage it considers deprecated. Therefore, removing Migrate will always silence warnings.
  3. While my change in AngularJS introduce the warning (thanks for finding the cause by yourself!) I think jQuery Migrate should have warned about the original code as well as they are equivalent - in other words, in jQuery in HTML mode elem.attr(booleanAttr, false) is equivalent to elem.removeAttr(booleanAttr).
  4. The warning means that boolean properties should be handled instead of boolean attributes, i.e. the prop method should be used instead of attr. Just using attr may not update some boolean properties properly. AngularJS updates the attributes but it also updates the properties. Therefore, we're already doing what Migrate advises to do here, we just also update attributes. Migrate cannot know we're doing both so it warns but this warning should be harmless.

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

No branches or pull requests

2 participants