Many sites now use various means to update their version of jQuery to a later version than 1.4, the version in Drupal 7.

jQuery deprecated (version 1.6) and removed (version 1.9) the use of .attr() for use to set "checked" and "disabled" properties. It also points out that attempting to retrieve values by using .attr() will result in confusion/problems, as in this example: $elem.attr("checked"); will return true if $elem has a "checked" property at all, not if it is true.

jQuery now uses .prop() instead to set and retrieve the value of a "checked" or "disabled" properties of a node.

.removeAttr() may also cause problems/unexpected behavior, as it completely removes the property rather than setting it to false, consequently it will no longer be selectable by selectors that typically would work. 
Example: 
Using <code>jQuery('input[name="test"]').removeAttr('checked');

on <input name="test" type="checkbox" checked="true" /> will result in <input name="test" type="checkbox" />. This is typically not the intended result, as it will cause CSS and jQuery selectors that you would expect to be able to find that item to fail.
Example: jQuery('input[checked]') will now fail to return this node.

See: jQuery 1.9 Upgrade Guide: attr vs. prop

It looks like the jQuery Update module's newest dev branch (7.x-3.x-dev) is including an option via a patch for using jQuery Migrate, which fixes compatibility with legacy jQuery code in newer version of jQuery. However, since most users will not move to that branch until it is out of dev, either a dependency on certain versions of jQuery and possibly certain settings in jQuery update need to be addressed, or the code in question should be made to work with all versions of jQuery.

There seem to be a few ways of going about this:

  1. Detect the version of jQuery in use and use code that works with that, this seems like it would add a lot of code doing the same thing, but for different versions of jQuery - YUCK!
  2. Force a full dependency on the jQuery update module and and a >X version of jQuery and update all code to use the newer version
  3. If using the jQuery update module, require the 3.x branch, as it includes jQuery migrate - not sure if feasible or possible to have a module somewhat dependent...
  4. Include the jQuery migrate plugin if the detected version of jQuery is not the expected one from original core and the migrate plugin isn't already included
  5. I reported a similar bug on the imagecache_actions module queue and a user submitted a great looking patch that switched the code to the form #states API, allowing drupal to handle it natively, which should work great...whatever version of jQuery you have gets used then...imagecache_actions solution/patch

My first inclination is that #4 or #5 sound the most feasible.

There could be additional options or combinations of these that are better, I am just trying to help the discussion get started and once we have a viable solution, potentially help roll patches.

possible problems:

File: views/js/base.js

  1. Line 23 $('#views-removed-' + id).attr('checked', true);
  2. Line 35: $('#display-removed-' + id).attr('checked', true);

File: views/js/views-admin.js

  1. Line 777: $(this).attr('checked', checked);
  2. Line 784: $('#edit-options-value-all').removeAttr('checked');
  3. Line 868: change_default_widget($(this).attr("checked"));
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DrCord’s picture

Issue summary: View changes
DrCord’s picture

Silicon.Valet’s picture

Here's a possible patch using jQuery's .get() dom access and vanilla JS .checked.

DamienMcKenna’s picture

Version: 7.x-3.8 » 7.x-3.x-dev
Status: Active » Needs review

Thanks for the patch. Lets see if it still applies against 7.x-3.x.

Status: Needs review » Needs work

The last submitted patch, 4: patch.diff, failed testing. View results

Silicon.Valet’s picture

Tweaking the paths in the patch.

The js files themselves look unchanged.

DamienMcKenna’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: views-jquery-compatibility-2416623-4.patch, failed testing. View results

DamienMcKenna’s picture

Seems like it needs a reroll.

alexdmccabe’s picture

Status: Needs work » Needs review
FileSize
2.17 KB
3.93 KB
DamienMcKenna’s picture

Thanks for the reroll.

Let's add this to the next release.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed. Thank you.

DamienMcKenna’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

poker10’s picture

It seems like that this change caused regression in views exposed filters settings. See: #3276983: Expose this filter javascript error: Uncaught TypeError: Cannot set properties of undefined (setting 'checked')