Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/prototype/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@
}

/**
* Element.insert(@element, content) -> Element
* Element.insert(@element, content [, content, ...]) -> Element
* - content (String | Element | Object): The content to insert.
*
* Inserts content `above`, `below`, at the `top`, and/or at the `bottom` of
Expand All @@ -901,6 +901,7 @@
* - ...any object with a `toElement` method: The method is called and the resulting element used
* - ...any object with a `toHTML` method: The method is called and the resulting HTML string
* is parsed and rendered
* - ...an array with any of the above as alements or an array
*
* The `content` argument can be the content to insert, in which case the
* implied insertion point is `bottom`, or an object that specifies one or
Expand Down Expand Up @@ -935,13 +936,24 @@
**/
function insert(element, insertions) {
element = $(element);

if (isContent(insertions))

if ( arguments.length > 2 ) {
insertions = Array.prototype.slice.call( arguments, 1 );
}

if ( Object.isArray( insertions ) ) {
for( var i = 0; i < insertions.length; ++i ) {
insert( element, insertions[i] );
}
return element;
}

if ( isContent(insertions) )
insertions = { bottom: insertions };

for (var position in insertions)
insertContentAt(element, insertions[position], position);

return element;
}

Expand Down Expand Up @@ -3478,4 +3490,4 @@
if (window.attachEvent)
window.attachEvent('onunload', destroyCache_IE);

})(this);
})(this);