[Zope3-dev] Re: [Checkins] SVN: z3c.form/trunk/src/z3c/form/ HTML element ids containing dots are not very good, because then the

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Jun 13 01:22:37 EDT 2007


Hello Gary,

I am sorry that it took me so long to respond, but I had to think about this 
problem for while and family is in town as well.

On Sunday 03 June 2007 14:18, Gary Poster wrote:
> Hey.  I've only had limited time to look at the new package(s) but  
> what I've seen so far looks good.  I hope to give it a whirl soon.

You should!

> You may want to check about the browser compatibility of having ids  
> and names different. I know I used to have IE problems when I did   
> this.  I tried to Google for verification.  I think you'll find some  
> here:
>
> http://channel9.msdn.com/wiki/default.aspx/
> Channel9.InternetExplorerProgrammingBugs
>
> Look for the section titled "META tags improperly "register" them  
> selfs as an ID with document.getElementById()", specifically the  
> *second* example.  AFAIK, this would be an IE6 thing; I don't have  
> much hands-on pain knowledge with IE7.

This example just shows me that the fix I checked in is correct. As it seems 
from the referenced report, the id and name share the same namespace with the 
name being given precendence. Thus problems occur only when an id is also 
used as a name somewhere else.

This checkin guarantees that the id and the name *never* share the same prefix 
namespace (ids use "-" and names "." as separators) thus eliminating the 
problem alltogether. Thus, if people use the JS functions as intended, 
everything should work great in IE.

> In fact, HTML 4 does regard name and id to be in the same namespace  
> for anchor tags (see http://www.w3.org/TR/html4/struct/links.html,  
> 12.2.3) and even requires that they be identical (example is in the  
> section).  The IE bug, apparently, is to assume that this constraint  
> holds for all name attributes, such as form fields.

But ids and names have to be only identical for the listed elements. For those 
this constraint does make sense. For INPUT and SELECT/OPTION elements this 
constraint does not make sense at all. As Roger points out later, for radio 
buttons, the "id" and "name" *must* even be different.

<input type="radio" name="question1" id="question1.option1" />
<input type="radio" name="question1" id="question1.option2" />

Reading the end of the section, I would think that using the "id" for the 
anchor name is even somewhat discouraged. In XHTML 1.0, on the other 
hand, "name" is just deprecated. See 
http://www.w3.org/TR/2002/REC-xhtml1-20020801/, section 4.10.

> So, what you did is technically correct.  However, if you want your  
> code to be used be folks who care about supporting IE6 and JS, I  
> believe you will want your names and ids to be identical.

I disagree with your conclusion. By ensuring that names and ids are always 
different, I avoid the namespace issue.

> I've rung this alarm bell before in other contexts, but this is the  
> first time I was able to find corroboration.

If you can send me a z3c.form-based form that does not behave correctly in 
IE6, I will be more than glad to revert this change and find another solution 
to the problem.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-dev mailing list