Site Navigation

Showing posts with label Mootools. Show all posts
Showing posts with label Mootools. Show all posts

Wednesday, August 5, 2009

bug 409 - MooTools redundant getElementById(id) method

Issue: #409
Affects: MooTools

If you are developing any web sites or web applications these days you are undoubtedly using a JavaScript Framework or have plans to implement one soon.


This bug is about the MooTools framework, specifically about the Element.getElementById() method.

The docs indicate:
Synopsis: Gets the element with the specified id found inside the current Element.
Example: var myChild = $('myParent').getElementById('myChild');
Notes: This method is not provided for Document instances as document.getElementById is provided natively.


Did you spot it? No? Lets run through it bit by bit.

For starters MooTools uses a very simple $('someID') syntax to get an element by its ID.

Combine that with the fact that the ID attribute of HTML elements must be unique within the document according to the W3C specs... and you've now proven that the .getElementById() method on any other element in the DOM is redundant.

E.g. the above example can also be written as (and in much less code I might add):
Example: var myChild = $('myChild');

Now maybe I'm missing something here that is hidden in the docs that helps explain why verbose, redundant code is somehow helpful or that it provides additional features? If so, please comment and let me know!



Known Workarounds: One. Simply don't use it! Its too bad that the API is cluttered with this extra method but it won't cause any harm to use it.

Example Workaround Code:

var myChild = $('myChild');



When you consider that your JavaScript Framework is providing an API on top of the existing JavaScript/ECMAScript API... you want your Framework API to be as simple and lightweight as possible. Its a minor bug but one that should be addressed to maintain a clean and tight API.

Related Issues: None.

Bug/Site Feedback |
Submit a bug

Tuesday, May 13, 2008

bug 326 - field names in IE that break with Mootools

Issue: #326
Affects: IE6, IE7, IE8 Beta 1?
JS Library: Mootools
Mootools Trac#:798

The following fields (name or id) will cause issues in Mootools:

"addEvent", "match", "position", "search"

Due to conflicts when the name exists in Element.Prototype, it will cause issues.

Example:
These will fail when you try to iterate using .each (for example) over a form element array.

<input id="addEvent"/>
<input id="match"/>
<input id="position"/>
<input id="search"/>

<input name="addEvent"/>
<input name="match"/>
<input name="position"/>
<input name="search"/>



Known Workarounds: None. (other than to be careful not to use these field identifiers)


Related Issues: None.

Bug/Site Feedback |
Submit a bug