While I agree that it is bad practice to use names and id's which conflict,
unfortunately we're not always scripting markup that we have control over.
I do think this should be handled in prototype, and the ticket is here:

http://dev.rubyonrails.org/ticket/6328

I recently reopened this ticket since it had been closed as a browser bug.
Prototype smooths over so many browser inconsistencies that I don't quite
understand that rationale.  Hopefully it will be reconsidered since I added
a patch with a test.  The performance hit should only occur in an edge case
in IE and Opera, so I don't see that as an issue.  Even then, dollar-dollar
is pretty fast these days, so I doubt it would be noticeable.

If you have some suggestions regarding the patch, please add your comments
to the ticket.

- Adam

On 6/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> I do not think so, what about this case:
> <script src="prototype.js"></script>
> <input type="text" value="ie bug" name="test" />
> <input type="text" value="this value should be returned" id="test" />
> <script>
> alert($("test").value)
> </script>
> If use your $ in ie and opera it will return null, but it should
> return the element which has the id "test" element, so I use $$ and
> detect the first matched element. My purpose is let the $ function has
> the same result on all the browsers. No matter ie opera or firefox or
> safari
> On Jun 17, 8:00 pm, DK <[EMAIL PROTECTED]> wrote:
> > I agree with jdalton - performance hit.
> > I agree also that you shouldn't use the same values for name's and
> > id's.
> >
> > $() is made for one purpose - to find elements with given id. It
> > should be VERY fast in every case as it's a base function of
> > Prototype.
> >
> > IMO, if found' element's id isn't the same as given, maybe function
> > should even return null:
> > [...]
> >     if (typeof element == 'string')
> >     {
> >         var id=element;
> >         element = document.getElementById(element);
> >         // not found
> >         if (element === null || !element.id || element.id!=id) {
> >             return null;
> >         }
> >     }
> >   return Element.extend(element);
> > [...]
> >
> > On Jun 17, 11:36 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Wait for your solution, however this performance hit only occur in the
> > > ie and opera and you select the input without an id attribute, maybe
> > > 1%'s probability. Will $$("*").detect take a very long time? long than
> > > 2 seconds? Is that posibble? Thanks- Hide quoted text -
> >
> > - Show quoted text -
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to