Merge "Use mw.cookie instead of $.cookie"

This commit is contained in:
jenkins-bot 2020-06-03 11:12:01 +00:00 committed by Gerrit Code Review
commit 850fb00009
3 changed files with 5 additions and 5 deletions

View file

@ -81,7 +81,7 @@
"ext.thanks.thank.js"
],
"dependencies": [
"jquery.cookie",
"mediawiki.cookie",
"mediawiki.api"
]
},

View file

@ -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 ) {

View file

@ -8,13 +8,13 @@ QUnit.module( 'Thanks thank', QUnit.newMwEnvironment( {
QUnit.test( 'thanked cookie', function ( assert ) {
var $thankLink = $( '<a ' + mw.thanks.thanked.attrName + '="8" />' ),
$thankLinkNonExisting = $( '<a ' + mw.thanks.thanked.attrName + '="13" />' );
$.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 );