Fix using JavaScript protocol in a.href

This commit is contained in:
printempw 2018-02-16 20:15:26 +08:00
parent 3ebc206e7d
commit 90af85d00f
2 changed files with 6 additions and 6 deletions

View File

@ -513,18 +513,18 @@ describe('tests for "operations" module', () => {
const updateTextureStatus = require(modulePath).updateTextureStatus;
updateTextureStatus(1, 'add');
expect($('a[tid=1]').attr('href')).toBe('javascript:removeFromCloset(1);');
expect($('a[tid=1]').attr('onclick')).toBe('removeFromCloset(1);');
expect($('a[tid=1]').attr('title')).toBe('skinlib.removeFromCloset');
expect($('a[tid=1]').hasClass('liked')).toBe(true);
expect($('#1').attr('href')).toBe('javascript:removeFromCloset(1);');
expect($('#1').attr('onclick')).toBe('removeFromCloset(1);');
expect($('#1').html()).toBe('skinlib.removeFromCloset');
expect($('div').html()).toBe('6');
updateTextureStatus(1, 'remove');
expect($('a[tid=1]').attr('href')).toBe('javascript:addToCloset(1);');
expect($('a[tid=1]').attr('onclick')).toBe('addToCloset(1);');
expect($('a[tid=1]').attr('title')).toBe('skinlib.addToCloset');
expect($('a[tid=1]').hasClass('liked')).toBe(false);
expect($('#1').attr('href')).toBe('javascript:addToCloset(1);');
expect($('#1').attr('onclick')).toBe('addToCloset(1);');
expect($('#1').html()).toBe('skinlib.addToCloset');
expect($('div').html()).toBe('5');
});

View File

@ -142,11 +142,11 @@ function updateTextureStatus(tid, action) {
action = (action === 'add') ? 'removeFromCloset' : 'addToCloset';
$(`a[tid=${tid}]`)
.attr('href', `javascript:${action}(${tid});`)
.attr('onclick', `${action}(${tid});`)
.attr('title', trans(`skinlib.${action}`))
.toggleClass('liked');
$(`#${tid}`)
.attr('href', `javascript:${action}(${tid});`)
.attr('onclick', `${action}(${tid});`)
.html(trans(`skinlib.${action}`));
$('#likes').html(likes);
}