Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#840 closed enhancement (invalid)

Linker plugin mystery

Reported by: mokhet Owned by: gogo
Priority: lowest Milestone:
Component: Plugin_Linker Version:
Severity: normal Keywords: linker obfuscated name identifier
Cc:

Description

In the file dialog.html we can find a lot of stuff like this [mailtable], [urltable], [anchortable], etc.

document.getElementById('[mailtable]').style.display=this.checked?'':'none';
document.getElementById('[urltable]').style.display=this.checked?'none':'';
document.getElementById('[anchortable]').style.display=this.checked?'none':'';

ALL elements names and id are surounded by brackets [MyName?], [MyID], etc. I dont understand why it is done this way and why it is not giving them correct names and id from start. I've looked to the code to find where the transformation from [weirdBracketName] to normalName occurs, but i didnt succeed in finding this piece of code.

Look at this one, it is even more weird (the [p_options])

  <th align="left"><l10n>Menu Bar:</l10n></th>
  <td><input type="checkbox" name="[p_options]" value="menubar=yes" /></td>
  <th align="left"><l10n>Toolbar:</l10n></th>
  <td><input type="checkbox" name="[p_options]" value="toolbar=yes" checked /></td>
</tr>
<tr>
  <th align="left"><l10n>Location Bar:</l10n></th>
  <td><input type="checkbox" name="[p_options]" value="location=yes" /></td>
  <th align="left"><l10n>Status Bar:</l10n></th>
  <td><input type="checkbox" name="[p_options]" value="status=yes"   /></td>

Thoses checkboxes are using the same name, which is totally invalid. As a result, the transformation give them the same name. This is totally wrong imo because checboxes are not treated as radio button and so they can not have the same name. They all should have a real different name from each other and instead of using the value to find the real name (location=yes, status=yes), it should already be named correctly from the start.

I find it even more weird since in linker.js the real names and id are used. This is obfuscating the code, most probably making useless loops and worst imo this can lead to not understandable evil errors.

Anyone knows why it is done this way and where is the piece of code transforming thoses weird name to more friendly stuff ?

Change History (2)

comment:1 Changed 13 years ago by gogo

  • Resolution set to invalid
  • Status changed from new to closed

Reason is simple - there may be multiple copies of the (inline) dialog open on the same page at once, and only one instance of any given ID may be present on any page at once. Therefore each instance of the elements in the dialog must get it's own unique ID.

Checkboxes can have the same name, nothing wrong with that perfectly valid - in this case we need them to have the same name so we can find all the checkboxes by that name and grab the values of the checked ones to use them as options to the popup window link you are creating. All perfectly valid.

The replacements of these special codes to unique id's per dialog is in source:trunk/inline-dialog.js

comment:2 Changed 13 years ago by mokhet

I obviously understand the reason to keep unique ID, but i dont understand why using something so complicated. They dont needs any unique ID since they are form elements, a unique name can be give to the form elements and then just accessing them trough the generic document.forms.elements collection.

What i dont understand is why creating a complicated system to be able to use getElementById() when there is an easy way that is already exists (doc.forms[name].elements[name]) and that's dont require to create any line of code.

Note: See TracTickets for help on using tickets.