Mislav, what are the general plans for the Insertion rewrite?  Aren't
these totally different things? Insertion is for HTML snippets and
these are pure DOM methods.

Ken, a few suggestions for your code..
Don't use .down and .next with no arguments unless you need non-text
nodes. It is very inefficient in this case. next grabs all nextSibling
elements recursively (potentially many, extending each one in the
process) and then just returns the first one. down grabs *all*
descendants, then loops through extending each one, and then returns
the first one.

I suggest only using those methods if you need guarantees that you are
getting a DOM element and not a text node. In this case I would argue
that you *do* want text nodes. Consider:

<div id="content">
  This is the content text
  <p id="subcontent">This is a paragraph</p>

var newNode = document.createElement('div');
newNode.innerHTML = 'This is the new content';
//would result in:
<div id="content">
  This is the content text
  <div>This is the new content</div>
  <p id="subcontent">This is a paragraph</p>

That is probably not the desired effect, at least since you are trying
to follow the behavior of appendChild and insertBefore. Go back to
nextSibling and firstChild for these functions.

This is moot if you consider my first suggestion, but where you used
refNode.next() you don't ensure that refNode is extended so you'll get
"no such property" errors on elements that haven't explicitly been
extended by Prototype yet.

Lastly, if this is to become Prototype code, it should follow the
Prototype conventions and accept strings representing ids for any
argument that is to be an element, and they should be chainable
anywhere that it makes sense so really we just need a fresh new API
for this stuff. I like the mootools implementation, simple and


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 

Reply via email to