[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 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Prototype-core] Re: Selector.findChildElements issue
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
[Prototype-core] Re: Deprecation.js
On 14/02/2008, Richard Quadling [EMAIL PROTECTED] wrote: On 14/02/2008, Tobie Langel [EMAIL PROTECTED] wrote: Hi Richard, Thanks for the thumbs up. deprecation.js is meant to be used with prototype.js, not a subset of it, so I don't think that's really an issue for now. The plan is to keep this new prototype extension up to date with the changes in Prototype, so once we remove the Position object, we'll add it to deprecation.js. Aha. Ok. I see. I was getting ahead of the game by taking out Postition before its time. Thanks. On Feb 14, 11:02 am, Richard Quadling [EMAIL PROTECTED] wrote: Hi. If you comment out from prototype.js the deprecated functions/classes (I take out the whole Position class for example), then deprecation.js fails due to the lack of the namespace: Position. So, using v1.6.0.2, should Position be defined but unused and therefore be in the global namespace or should it be commented out and deprecation.js cope with its absence? (I can't quite decide if this is a core or a spinoff issue). Would it be possible to add a version number/build number to the extension please. -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Prototype-core] Re: Deprecation.js
Ya, I'm just trying to figure out a good way to do so as the plan is to tie it to a specific version of Prototype. Any suggestions welcomed. Best, Tobie On Feb 15, 12:58 pm, Richard Quadling [EMAIL PROTECTED] wrote: On 14/02/2008, Richard Quadling [EMAIL PROTECTED] wrote: On 14/02/2008, Tobie Langel [EMAIL PROTECTED] wrote: Hi Richard, Thanks for the thumbs up. deprecation.js is meant to be used with prototype.js, not a subset of it, so I don't think that's really an issue for now. The plan is to keep this new prototype extension up to date with the changes in Prototype, so once we remove the Position object, we'll add it to deprecation.js. Aha. Ok. I see. I was getting ahead of the game by taking out Postition before its time. Thanks. On Feb 14, 11:02 am, Richard Quadling [EMAIL PROTECTED] wrote: Hi. If you comment out from prototype.js the deprecated functions/classes (I take out the whole Position class for example), then deprecation.js fails due to the lack of the namespace: Position. So, using v1.6.0.2, should Position be defined but unused and therefore be in the global namespace or should it be commented out and deprecation.js cope with its absence? (I can't quite decide if this is a core or a spinoff issue). Would it be possible to add a version number/build number to the extension please. -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Prototype-core] Re: Attaching event to instance of object in class
On 14/02/2008, kojilab [EMAIL PROTECTED] wrote: Hi, I have a class with DOM elements as properties. I want to bind events within the class to the ements. Unfortunately I am getting an error telling me those properties are not defined. Here's an simplfied example of what I'm trying to achieve. var MyClass=Class.create() MyClass.prototye = { initialize: function(element1, element2){ this.element1=element1; this.element2=element2; }, hide: function(){ this.element2.hide(); } } Can you try ... var MyClass=Class.create() MyClass.prototye = { initialize: function(element1, element2){ this.element1=$(element1); this.element2=$(element2); this.element1.observe('click', this.hide).bindAsEventListener(this); }, hide: function(){ this.element2.hide(); } } Not sure what you are observing, so chose click. -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---