ya, the easiest solution will probably be:

  descendants: function(element) {
    return Element.select(element, "*");
  },


On Feb 15, 10:02 am, Andrés Robinet <[EMAIL PROTECTED]> wrote:
> -----Original Message-----
> > From: prototype-core@googlegroups.com [mailto:prototype-
> > [EMAIL PROTECTED] On Behalf Of Tobie Langel
> > Sent: Friday, February 15, 2008 3:16 AM
> > To: Prototype: Core
> > Subject: [Prototype-core] Re: Selector.findChildElements issue
>
> > Hi,
>
> > That is indeed a regression and we'll fix it.
>
> > However, I can't stop myself from wondering what kind of bizarre HTML
> > actually sports children for input tags ;)
>
> > Best,
>
> > Tobie
>
> > On Feb 15, 8:58 am, Andrés Robinet <[EMAIL PROTECTED]> wrote:
> > > > -----Original Message-----
> > > > From: Andrés Robinet [mailto:[EMAIL PROTECTED] On Behalf Of Andrés
> > > > Robinet
> > > > Sent: Friday, February 15, 2008 2:51 AM
> > > > To: 'prototype-core@googlegroups.com'
> > > > Subject: Selector.findChildElements issue
>
> > > > Hi All,
>
> > > > I found what appears to be a bug in Selector.findChildElements. I'm
> > using
> > > > prototype 1.6.0.2 and this behavior was not present in version 1.6.0.
> > I've
> > > > experienced this behavior on both IE 7 and FF 2 (didn't test other
> > > > browsers).
>
> > > > Calling element.descendants() on an input element will call
> > > > element.select('*') which in turn calls
> > Selector.findChildElements(element,
> > > > '*'). This function returns "undefined" for inputs, but returns an
> > iterable
> > > > object for other empty tags such as "hr" and "br", which is very odd
> > (it
> > > > should either return always undefined or always return an iterable -
> > empty-
> > > > object, shouldn't it?).
>
> > > > I didn't go deeper into details about why and where the "bug" exactly
> > is,
> > > > but I have this sample code as a proof of concept:
>
> > > >    <form action="whatever.php" method="post" enctype="application/x-
> > www-
> > > > form-urlencoded">
> > > >            <hr id="test-hr" />
> > > >            <input id="test-input" type="text" value="whatever" />
> > > >            <br id="test-br" />
> > > >    </form>
>
> > > >    <script language="javascript" type="text/javascript">
> > > >    //<![CDATA[
> > > >            document.observe('dom:loaded', function() {
> > > >                    // Test HR
> > > >                    var hrTest = $('test-hr')
> > > >                    var hrDesc = hrTest.descendants();
> > > >                    alert(typeof hrDesc);
> > > >                    alert(hrDesc.each);
> > > >                    // Test Input
> > > >                    var inputTest = $('test-input');
> > > >                    var inputDesc = inputTest.descendants();
> > > >                    alert(typeof inputDesc);
> > > >                    // alert(inputDesc.each); // Uncomment and you get a
> > JS
> > > > error
> > > >                    // Test BR
> > > >                    var brTest = $('test-br')
> > > >                    var brDesc = brTest.descendants();
> > > >                    alert(typeof brDesc);
> > > >                    alert(brDesc.each);
> > > >            });
> > > >    //]]>
> > > >    </script>
>
> > > > I tried searching trac, but found nothing specific to this issue.
>
> > > > Regards,
>
> > > > Rob
>
> > > > Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
> > > > 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL
> > > > 33308 | TEL 954-607-4207 | FAX 954-337-2695 |
> > > > Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
> > > > bestplace |  Web: bestplace.biz  | Web: seo-diy.com
>
> > > I found something similarhttp://dev.rubyonrails.org/ticket/11102, but
> > it's not
> > > the same (though it's probably related to it)
>
> > > Regards,
>
> > > Rob
>
> Hi Tobie,
>
> There's a cooltip library (same builders of modalbox). This library creates
> cooltips using the title tags of elements, and part of the job is searching 
> for
> the "alt" attribute on descendant tags to disable it (and avoid the browser
> showing its own tooltip). You add a cooltip to a form field (pretty common to 
> do
> so for form fields) and you get an error, since the library assumes 
> descendants
> is at least an empty array... HOWEVER, ALL I SAID IN PREVIOUS POSTS IS NOT 
> TRUE.
> This is the truth:
>
> elem.descendants calls elem.select('*'), but for inputs, elem.select('*') 
> makes
> no sense, since the "select" method will SELECT THE FORM CONTROL IN THE UI, 
> this
> is a method of Form.Elementhttp://prototypejs.org/api/form/element/selectwhich
> happens to have a native implementation (at least for 
> IEhttp://msdn2.microsoft.com/en-us/library/ms536733(VS.85).aspx) and this is 
> what
> prototype is actually calling... it's NOT calling Selector.findChildElements
>
> So... what should we do now? Clearly, it is ok that the select method is
> overridden for input controls, but the descendants method should still return
> consistent results.
>
> I've been playing around and any of the commented lines seems to work. 
> However,
> I think I'm not up to submit a patch (I can if you want, but never did before,
> and I'm not a JS or prototype guru, so don't trust my code). If some of you 
> can
> evaluate these or other alternatives, it would be great:
>
>   descendants: function(element) {
>     //return Element.Methods.select($(element), "*");
>     //return $($A($(element).getElementsByTagName("*")));
>     //return Selector.findChildElements($(element), ["*"]);
>     return $(element).select("*"); // Doesn't work on input fields  
>   },
>
> Regards,
>
> Rob
>
> Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 
> 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
> TEL 954-607-4207 | FAX 954-337-2695 |
> Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |
>  Web: bestplace.biz  | Web: seo-diy.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
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