Per the discovery in #1857042: [jquery_update] 3rd party libraries, the current location of the jquery.cookie.js replacement file is replace/ui/external/jquery.cookie.js. I suspect that it was added there as part of the jQuery UI implementation (#2534056: Remove unused and NON-MIT/GPL licensed or compatible code).

It should really be it's own separately supported library replacement and updated to the latest supported version.

It appears that https://github.com/carhartl/jquery-cookie/ has moved to https://github.com/js-cookie/js-cookie/ and deducing from the following comment the last version that has jQuery support (which we'll need) is version 1.5.1: https://github.com/carhartl/jquery-cookie/issues/349#issuecomment-116822133

---

JS Cookie 2.0+ no longer has jQuery integration. Moving forward, we'll have to create our own jQuery wrapper that does essentially what was done in 1.5.1 with a little extra to provide BC support from the https://github.com/js-cookie/js-cookie/releases/tag/v2.0.0 changes:

/**
  * @file
  * Exposes Cookies to jQuery for backwards compatibility in Drupal.
  */
(function ($, Cookies, Drupal) {

  // Retrieve cookie settings.
  var settings = Drupal.settings.jquery_update && Drupal.settings.jquery_update.cookies || {
    // The js-cookie plugin broke BC, this setting adds expected behavior back in
    // based on https://github.com/js-cookie/js-cookie/releases/tag/v2.0.0
    backwardsCompatibility: true
  };

  // Handle raw values.
  var CookiesHandler = Cookies.withConverter(function(value) {
    if (settings.backwardsCompatibility && CookiesHandler.raw) {
      return value;
    }
  });

  // Let the default path be the current page.
  if (settings.backwardsCompatibility) {
    CookiesHandler.defaults.path = '';
  }

  // Expose to jQuery.
  $.cookie = CookiesHandler;

  // Return boolean if the cookie was removed.
  // @see https://github.com/carhartl/jquery-cookie/blob/master/src/jquery.cookie.js#L111
  if (settings.backwardsCompatibility) {
    $.removeCookie = function () {
      CookiesHandler.remove.apply(CookiesHandler, arguments);
      return CookiesHandler.get.apply(CookiesHandler, Array.prototype.slice.apply(arguments, [0, 1])) === void 0;
    };
  }
  else {
    $.removeCookie = CookiesHandler.remove;
  }

})(jQuery, Cookies, Drupal)
CommentFileSizeAuthor
#1 update_jquery_cookie-2536698-1.patch7.02 KBnpacker
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

npacker’s picture

Status: Active » Needs review
FileSize
7.02 KB

I'd like to see jquery.cookie.js updated or moved as well. I'm currently working on bringing another jQuery plugin (Able Player) to drupal; it depends on a later version of jquery.cookie.js and jQuery Update does not help.

In the meantime, a patch for the updated version. Updating does not create any backwards-compatibility problems.

maximpodorov’s picture

Status: Needs review » Reviewed & tested by the community

This update includes really important fixes, such as:
https://github.com/carhartl/jquery-cookie/commit/ecb597b65e4c477baa2b30a...

markcarver’s picture

Title: Move and update jquery.cookie » Update jquery.cookie
Status: Reviewed & tested by the community » Postponed
Parent issue: » #1869928: Better CDN/API/automation support
Related issues: +#2852350: [jquery_update] 7.x-3.0 stable release

I was actually looking at this last night, but decided not to work on it since it really should be postponed on the CDN parent issue.

There are two repositories containing the same "code":

https://github.com/carhartl/jquery-cookie/

and

https://github.com/js-cookie/js-cookie/

Somehow we'll need to "merge" these two sources so a user has the ability to choose which version (in case the latest doesn't work for them).

maximpodorov’s picture

BTW, the patch can be applied to 7.x-2.x also.

markcarver’s picture

The 7.x-2.x branch is no longer being maintained or will have patches applied to it.

maximpodorov’s picture

Maybe it's better to provide an option which version to use as a replacement? The safe default can be 1.4.1 which is compatible with Drupal core's version of jquery.cookie.

markcarver’s picture

Issue summary: View changes

Maybe it's better to provide an option which version to use as a replacement?

Yes, which is why this is postponed on the CDN issue.

The safe default can be 1.4.1 which is compatible with Drupal core's version of jquery.cookie

It's actually not that difficult to just add the functionality back in so we can have the best of both worlds. I've updated the issue summary with the example code I was imagining.

markcarver’s picture

Issue summary: View changes
markcarver’s picture

And we can easily provide a "Backwards Compatibility" checkbox (which can be enabled by default) if the version selected is > 1.5.1.