switch (arg.charAt(0)) ... should be ... switch (arg[0])

wish we could edit these posts...

On Mar 12, 6:31 pm, Jason Mulligan <[email protected]>
wrote:
> Hi,
>
> I just released abaaso 1.2 and I'd love some feedback on the global
> helper, aka $(). It's sole purpose in the lib is to retrieve Elements,
> it's not like jQuery; all the real code sits in a global namespace.
>
> /**
>  * Returns an instance or array of instances
>  *
>  * @param arg {string} Comma delimited string of target element.id
> values
>  * @param nodelist {boolean} [Optional] True will return a NodeList
> (by reference) for tags & classes
>  * @returns {mixed} instances Instance or Array of Instances
>  */
> $ : function(arg, nodelist) {
>         try {
>                 arg      = (arg.toString().indexOf(",") > -1) ? 
> arg.split(",") :
> arg;
>                 nodelist = (nodelist === true) ? true : false;
>
>                 if (arg instanceof Array) {
>                         var instances = [],
>                             i         = arg.length;
>
>                         while (i--) {
>                                 instances.push($(arg[i], nodelist));
>                         }
>
>                         return instances;
>                 }
>
>                 var obj;
>                 arg = new String(arg);
>
>                 switch (arg.charAt(0)) {
>                         case ".":
>                                 obj = 
> document.getElementsByClassName(arg.substring(1));
>                                 (nodelist === false) ? obj = 
> Array.prototype.slice.call(obj) :
> void(0);
>                                 break;
>                         case "#":
>                                 obj = 
> document.getElementById(arg.substring(1));
>                                 break;
>                         default:
>                                 obj = document.getElementsByTagName(arg);
>                                 (nodelist === false) ? obj = 
> Array.prototype.slice.call(obj) :
> void(0);
>                                 break;
>                 }
>
>                 obj = (obj === null) ? undefined : obj;
>                 return obj;
>         }
>         catch (e) {
>                 error(e);
>                 return undefined;
>         }
>
>
>
>
>
>
>
> }

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to