This project is archived and is in readonly mode.

#656 ✓resolved
Yasser

Element.implement functions not available through Elements

Reported by Yasser | May 3rd, 2009 @ 12:28 AM | in 1.2.3

With 1.2.2, none of the functions I've defined using Element.implement({}) are available through Elements objects. I'm sure it has something to do with the new Class stuff, but I'm not well-versed enough in Mootools to know if this is my error or a bug.

Comments and changes to this ticket

  • Scott Kyle

    Scott Kyle May 3rd, 2009 @ 02:40 AM

    I wasn't able to reproduce this bug. The Element code isn't related to the Class code. Are you running your DOM method on domready? Here's the code I used to check this bug:

    
    Element.implement({
    	fill : function() {
    		return this.set('text', 'filled');
    	}
    });
    			
    $$('.fillme').fill();
    
  • Yasser

    Yasser May 3rd, 2009 @ 04:52 AM

    All of my functions are called on domready, including my call to Element.implement (which is the first thing called). The code works fine with 1.2.1 and the previous version of More.

    I guess I'm stumped.

  • Yasser

    Yasser May 3rd, 2009 @ 05:05 AM

    The code in question:

    This method "setActiveList" is called as a "click" event.

    
    setActiveList: function(r, a){
    	$$("ul.contacts","div.listdetails").switchClass(r, a).each(function(ul){
    		if(ul.hasClass('list')){
    			ul.getChildren("li").removeClass("alt").hide();
    			ul.getChildren("li."+a).alternate().show();
    		};
    	});
    }
    

    In Element.implement():

    
    switchClass: function(remove, add){
    	this.removeClass(remove);
    	this.addClass(add);
    	return this;
    }
    

    As well as the show() and hide() methods. The script tanks when switchClass is called.

  • Thomas Aylott

    Thomas Aylott May 3rd, 2009 @ 02:42 PM

    • Assigned user set to “Valerio”
    • Tag changed from 1.2.2, class to 1.2.2, class, regression
    • Milestone changed from 2.0 to 1.2.3
  • Scott Kyle

    Scott Kyle May 3rd, 2009 @ 02:43 PM

    • Assigned user cleared.
    • Tag changed from 1.2.2, class, regression to 1.2.2, class

    Few things:

    1. This most likely is not a bug and therefore I'd like you to email me the whole piece of relevant code and I'll let ya know what's going wrong.
    2. If setActiveList is being called directly as a click handler, then an Event object would be passed in, again I'll check out your code and let you know what's up.
    3. FYI, in MooTools-more there is a module called Element.Shortcuts that gives you already written swapClass(), show(), hide(), and more methods.
  • Yasser

    Yasser May 3rd, 2009 @ 05:19 PM

    After pulling my hair out for a while trying to figure this out, I believe this is a Webkit bug and not a Mootools bug.

    The system I was testing on had a version of Safari 4 with the tabs below the menu bar (a la Safari 3), so I didn't realize I was testing in a beta browser. Perhaps this is related to the Class.implement() bug you described on your blog.

    I'm going to go ahead and submit a bug to Webkit.org.

  • Scott Kyle

    Scott Kyle May 3rd, 2009 @ 11:28 PM

    Haha yea, I was actually wondering if you were using Safari 4. It is directly related to what I wrote about, which is that after you add to a prototype, you won't be able to loop through what you added into that prototype in Safari 4.

    If you haven't already, don't submit a bug to Webkit, because like I said in my blog post, the Webkit Nightlies have already been fixed. I submitted my bug to Apple so that they can make sure to merge that fix into their Safari 4 branch before release.

    Please don't take this as me being rude, but please test your bugs in another browser if possible, and report which browser(s) that bug is occurring in next time. I'll admit, I'm not that diligent sometimes as well. :-)

  • Yasser

    Yasser May 3rd, 2009 @ 11:35 PM

    No offense taken. I'm not a huge Firefox user, and hadn't noticed that I was using Safari 4 instead of 3.2.1. Hopefully Apple will update their branch before pushing Safari 4 out to the masses. Thanks for your help.

  • Scott Kyle

    Scott Kyle May 13th, 2009 @ 04:54 AM

    FYI, today's Safari 4 update fixes the prototype enumeration bug. So this should work now! :-)

  • Valerio

    Valerio June 14th, 2009 @ 03:22 AM

    • State changed from “new” to “resolved”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Tags

Pages