From 3d17c58922b88fcf6ae75764d254bda11a395a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Fri, 29 May 2020 19:43:31 +0000 Subject: [PATCH] Use mw.cookie instead of $.cookie Bug: T254024 Change-Id: If487ef4d14f308fd6da0d6b938e35dc68dca5b5e --- extension.json | 2 +- modules/ext.thanks.thank.js | 4 ++-- tests/qunit/test_ext.thanks.thank.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extension.json b/extension.json index 92447df3..c0b3bb58 100644 --- a/extension.json +++ b/extension.json @@ -81,7 +81,7 @@ "ext.thanks.thank.js" ], "dependencies": [ - "jquery.cookie", + "mediawiki.cookie", "mediawiki.api" ] }, diff --git a/modules/ext.thanks.thank.js b/modules/ext.thanks.thank.js index b8bde7ce..ca5c46dd 100644 --- a/modules/ext.thanks.thank.js +++ b/modules/ext.thanks.thank.js @@ -9,7 +9,7 @@ attrName: 'data-revision-id', load: function () { - var cookie = $.cookie( this.cookieName ); + var cookie = mw.cookie.get( this.cookieName ); if ( cookie === null ) { return []; } @@ -22,7 +22,7 @@ if ( saved.length > this.maxHistory ) { // prevent forever growing saved = saved.slice( saved.length - this.maxHistory ); } - $.cookie( this.cookieName, escape( saved.join( ',' ) ) ); + mw.cookie.set( this.cookieName, escape( saved.join( ',' ) ) ); }, contains: function ( $thankLink ) { diff --git a/tests/qunit/test_ext.thanks.thank.js b/tests/qunit/test_ext.thanks.thank.js index bdb71eac..c393267f 100644 --- a/tests/qunit/test_ext.thanks.thank.js +++ b/tests/qunit/test_ext.thanks.thank.js @@ -8,13 +8,13 @@ QUnit.module( 'Thanks thank', QUnit.newMwEnvironment( { QUnit.test( 'thanked cookie', function ( assert ) { var $thankLink = $( '' ), $thankLinkNonExisting = $( '' ); - $.cookie( mw.thanks.thanked.cookieName, escape( '17,11' ) ); + mw.cookie.set( mw.thanks.thanked.cookieName, escape( '17,11' ) ); assert.deepEqual( mw.thanks.thanked.load(), [ '17', '11' ], 'gets cookie with two values' ); // Makes the 0 100th element // eslint-disable-next-line no-restricted-properties - $.cookie( mw.thanks.thanked.cookieName, escape( '9,'.repeat( mw.thanks.thanked.maxHistory - 1 ) + '0' ) ); + mw.cookie.set( mw.thanks.thanked.cookieName, escape( '9,'.repeat( mw.thanks.thanked.maxHistory - 1 ) + '0' ) ); assert.strictEqual( mw.thanks.thanked.load()[ mw.thanks.thanked.maxHistory - 1 ], '0', 'loads ' + mw.thanks.thanked.maxHistory + ' ids from a cookie' ); mw.thanks.thanked.push( $thankLink );