Skip to content

Commit a19a97d

Browse files
committed
Use a data-id element for rule toggling.
Per amo-validator advice, we should avoid setting oncommand attributes using interpolated JS. Instead this puts one constant oncommand attribute in the XUL, which pull the necessary rule id from a data attribute.
1 parent c562f8c commit a19a97d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/chrome/content/code/ApplicableList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ ApplicableList.prototype = {
213213
},
214214

215215
add_command: function(rule) {
216-
var command = this.document.createElement("command");
216+
var command = this.document.getElementById("https-everywhere-menuitem-rule-toggle-template").cloneNode();
217217
command.setAttribute('id', JSON.stringify(rule.id)+'-command');
218+
command.setAttribute('data-id', JSON.stringify(rule.id));
218219
command.setAttribute('label', rule.name);
219-
command.setAttribute('oncommand', 'toggle_rule("'+JSON.stringify(rule.id)+'")');
220220
this.commandset.appendChild(command);
221221
},
222222

src/chrome/content/toolbar_button.xul

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@
5757
</toolbarbutton>
5858
</toolbarpalette>
5959
<commandset>
60+
<command id="https-everywhere-menuitem-rule-toggle-template"
61+
oncommand="toggle_rule(event.target.attributes['data-id'].value)" />
6062
<command id="https-everywhere-menuitem-resetToDefaults"
6163
oncommand="httpsEverywhere.toolbarButton.resetToDefaults()" />
6264
<command id="https-everywhere-menuitem-globalEnableToggle"
6365
oncommand="toggleEnabledState();" />
6466
<command id="https-everywhere-menuitem-about"
6567
oncommand="HTTPSEverywhere.chrome_opener('chrome://https-everywhere/content/about.xul');" />
66-
<command id="https-everywhere-menuitem-birthday"
67-
oncommand="open_in_tab('https://www.eff.org/EFF25');" />
6868
<command id="https-everywhere-menuitem-observatory"
6969
oncommand="HTTPSEverywhere.chrome_opener('chrome://https-everywhere/content/observatory-preferences.xul', 'chrome,centerscreen,resizable=yes');" />
70-
<command id="https-everywhere-menuitem-donate-eff"
70+
<command id="https-everywhere-menuitem-donate-eff"
7171
oncommand="open_in_tab('https://www.eff.org/donate');" />
72-
<command id="https-everywhere-menuitem-donate-tor"
72+
<command id="https-everywhere-menuitem-donate-tor"
7373
oncommand="open_in_tab('https://www.torproject.org/donate');" />
74-
<command id="https-everywhere-menuitem-ruleset-tests"
74+
<command id="https-everywhere-menuitem-ruleset-tests"
7575
oncommand="openStatus();" />
7676
</commandset>
7777
</overlay>

0 commit comments

Comments
 (0)