Skip to content

Commit

Permalink
Issue #2550717 follow-up by bnjmnm, tedbow, lauriii: [JS] Replace jQu…
Browse files Browse the repository at this point in the history
…ery.cookie with JS-cookie and provide a BC layer
  • Loading branch information
lauriii committed Mar 19, 2020
1 parent 6e9d3de commit 299b8c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions core.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ jquery.cookie:
- core/jquery
- core/drupal
- core/js-cookie
- core/drupal.object.assign

jquery.farbtastic:
remote: https://github.com/mattfarina/farbtastic
Expand Down Expand Up @@ -1033,5 +1034,3 @@ js-cookie:
gpl-compatible: true
js:
assets/vendor/js-cookie/js.cookie.min.js: {}
dependencies:
- core/drupal.object.assign
4 changes: 2 additions & 2 deletions misc/jquery.cookie.shim.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
if (value !== undefined && !isFunction(value)) {
// The caller is setting a cookie value and not trying to retrieve the
// cookie value using a converter callback.
const attributes = Object.assign($.cookie.defaults, options);
const attributes = Object.assign({}, $.cookie.defaults, options);

if (!$.cookie.json) {
// An object that is passed in must be typecast to a string when the
Expand Down Expand Up @@ -187,7 +187,7 @@
* @see https://github.com/js-cookie/js-cookie/blob/v2.2.1/README.md
*/
$.removeCookie = (key, options) => {
cookies.remove(key, Object.assign($.cookie.defaults, options));
cookies.remove(key, Object.assign({}, $.cookie.defaults, options));
return !cookies.get(key);
};
})(jQuery, Drupal, window.Cookies);
4 changes: 2 additions & 2 deletions misc/jquery.cookie.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;

if (value !== undefined && !isFunction(value)) {
var attributes = Object.assign($.cookie.defaults, options);
var attributes = Object.assign({}, $.cookie.defaults, options);

if (!$.cookie.json) {
value = String(value);
Expand Down Expand Up @@ -65,7 +65,7 @@
$.cookie.raw = false;

$.removeCookie = function (key, options) {
cookies.remove(key, Object.assign($.cookie.defaults, options));
cookies.remove(key, Object.assign({}, $.cookie.defaults, options));
return !cookies.get(key);
};
})(jQuery, Drupal, window.Cookies);

0 comments on commit 299b8c4

Please sign in to comment.