I'm trying to understand something about this example from the API
docs re: Element.addMethods:

  wrap: function(element, tagName) {
    element = $(element);
    var wrapper = document.createElement('tagName');
    element.parentNode.replaceChild(wrapper, element);
    return Element.extend(wrapper);

Why does the "wrap" function include the line "element = $(element);"?

In general, this line adds extra flexibility to a function.  But in
this case the function is defined in the context of
Element.addMethods, so wouldn't "element" always refer to a node in
the DOM already?  Is there a case where the method could fail if that
first line is not included?


You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to