Reduce use of new Function()

This commit is contained in:
YUKI Hiroshi 2016-09-07 15:46:45 +09:00
parent 9c26c3c9d2
commit 34adf858d0

View File

@ -15,8 +15,8 @@ function syncEnabledState(aElement, aEnabled)
{ {
if (typeof aElement == 'string') if (typeof aElement == 'string')
aElement = document.getElementById(aElement); aElement = document.getElementById(aElement);
if (typeof aEnabled == 'string') if (typeof aEnabled == 'function')
aEnabled = (new Function('return '+aEnabled)).call(aElement); aEnabled = aEnabled.call(aElement);
aElement.getAttribute('sync-enabled-state-targets') aElement.getAttribute('sync-enabled-state-targets')
.replace(/$\s+|\s+$/g, '') .replace(/$\s+|\s+$/g, '')
@ -291,9 +291,9 @@ function onSyncMaxTreeLevelPrefToUI(aTarget)
function initAutoHidePane() function initAutoHidePane()
{ {
syncEnabledState('extensions.treestyletab.tabbar.autoShow.mousemove-check', 'this.checked'); syncEnabledState('extensions.treestyletab.tabbar.autoShow.mousemove-check', function() { return this.checked; });
syncEnabledState('extensions.treestyletab.tabbar.autoShow.accelKeyDown-check', 'this.checked'); syncEnabledState('extensions.treestyletab.tabbar.autoShow.accelKeyDown-check', function() { return this.checked; });
syncEnabledState('extensions.treestyletab.tabbar.autoShow.feedback-check', 'this.checked'); syncEnabledState('extensions.treestyletab.tabbar.autoShow.feedback-check', function() { return this.checked; });
} }
function onChangeAutoHideMode(aRadioGroup, aTogglePref) function onChangeAutoHideMode(aRadioGroup, aTogglePref)
@ -305,7 +305,7 @@ function onChangeAutoHideMode(aRadioGroup, aTogglePref)
function initTreePane() function initTreePane()
{ {
syncEnabledState('extensions.treestyletab.closeParentBehavior-radiogroup', 'this.value == 0'); syncEnabledState('extensions.treestyletab.closeParentBehavior-radiogroup', function() { return this.value == 0; });
var focusMode = document.getElementById('extensions.treestyletab.focusMode-check'); var focusMode = document.getElementById('extensions.treestyletab.focusMode-check');
var focusModePref = document.getElementById('extensions.treestyletab.focusMode'); var focusModePref = document.getElementById('extensions.treestyletab.focusMode');