I'm having a piece of code very simple. It checks two parameters. If first parameter is false it change the popup icon in the chrome extension, if it's true and previously was false, then it change the icon backs and if no parameters is passed it returns the current values.
The problem is that either way, both the variable and the first parameter that is being passed as boolean, is interpreted as string and that produce unexpected results. Here's my code:
var status = true;
var reason;
function isReady(statusT, reasonT) {
"use strict";
if (statusT === false) {
chrome.browserAction.setIcon({
path : "img/blue-sharingan.png"
});
status = statusT;
if (reason !== undefined) {
reason = reasonT;
return;
}
return;
}
if (statusT === true && status === false) {
chrome.browserAction.setIcon({
path : "img/icon-32.png"
});
status = statusT;
reason = null;
return;
}
if (statusT === undefined && reasonT === undefined) {
return {
'status' : status,
'reason' : reason
};
}
}
I've read https://stackoverflow.com/a/653934/792066 and I still don't figure out what could be wrong.