Comments (8)
Matt Haggard
July 31st, 2009 @ 11:03 PM
Tag changed from “needs:discussion, performance, section:dom, syntax” to “needs:discussion, performance, section:dom, syntax”
Just yesterday I wanted the same thing. Here's a humble patch. I don't think I got the event handling right (content.evalScripts.bind(content).defer();), but the unit tests still pass on OS X. And it could probably be more efficient.
from prototype.
Tobie Langel
August 1st, 2009 @ 05:16 PM
State changed from “new” to “enhancement”
Tag changed from “needs:discussion, performance, section:dom, syntax” to “needs:discussion, section:dom”
Milestone set to “2.0”
Element#insert is going to be greatly revised for 2.0. It's worth discussing this in the meantime, but not making any changes on the current API.
from prototype.
Radoslav Stankov
August 3rd, 2009 @ 09:36 PM
If is possible, could I ask what is the in mind for Prototype 2.0 ? :)
Mean while if some one need such functionally a little monkey patch:
Element.addMethods({
insert: Element.insert.wrap(function(insert, element, insertation)){
if (!Object.isArray(insertation)) return insert(element, insertation);
element = $(element);
insertation.each(insert.curry(element));
return element;
}
});
p.s. I haven't made decent tests, but maybe something like this could be faster:
var fragment = document.createDocumentFragment();
insertation.each(fragment.appendChild.bind(fragment));
element.appendChild(fragment);
from prototype.
dennis
October 23rd, 2011 @ 09:38 PM
Importance changed from “” to “”
2 years and pushing it to 2.0? Seriously?
In Elements.Methods.insert (version 1.7):
if (Object.isString(insertions) || Object.isNumber(insertions) || Object.isElement(insertions) ||
Object.isArray(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
...
if (Object.isArray(content)) {
content.each( function( ae ) {
insert( element, ae );
} );
continue;
}
Perhaps the iteration could be improved, but THAT'S IT!
from prototype.
dennis
December 7th, 2011 @ 12:37 AM
And when array handing is added, it will be easy to handle variable length arguments ...
insert: function(element, insertions) {
element = $(element);
if ( arguments.length > 2 ) {
insertions = Array.slice( arguments, 1 );
}
if (Object.isString(insertions) || Object.isNumber(insertions) ||
Object.isElement(insertions) || Object.isArray(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
var content, insert, tagName, childNodes;
for (var position in insertions) {
content = insertions[position];
position = position.toLowerCase();
insert = Element._insertionTranslations[position];
if (content && content.toElement) content = content.toElement();
if (Object.isArray(content)) {
content.each( function( ae ) {
insert( element, ae );
} );
continue;
}
if (Object.isElement(content)) {
insert(element, content);
continue;
}
from prototype.
dennis
December 14th, 2011 @ 03:35 PM
Ah, only Firefox agrees with this solution. I did some testing on current Chrome and Internet Explorer. Also, I did not thoroughly debug this but my guess is it's in the accessing/slicing of function arguments.
from prototype.
dennis
January 2nd, 2013 @ 01:09 AM
It seems Killemov implemented this quite elegantly in killemov@16ecf74043fa29950e2e3e... and he has made a pull request.
from prototype.
it seems https://github.com/sstephenson/prototype/pull/76/files
from prototype.
Related Issues (20)
- Native Array.prototype.filter is overwritten by prototype HOT 1
- Native Array.from is overwritten by $A which is not able to handle all cases used by the native function HOT 5
- Unable to build on Windows (no tar command) HOT 5
- Uncaught TypeError: $(...).getValue is not a function HOT 5
- Global.Node has the potential of being overwritten.
- Array.prototype.toJSON requires double parsing after stringify HOT 1
- Compatibility with RetroZilla HOT 6
- Security Issue: Request for contact HOT 4
- Uncaught SyntaxError: unexpected token: ':' HOT 2
- https://api.prototypejs.org/ seems to be down. HOT 3
- Warning: Potential Security Risk Ahead https://api.prototypejs.org/ HOT 1
- Fixing JS injection HOT 2
- Typescript declarations?
- CVE-2020-27511 HOT 5
- Element.replace() swaps element and textNode if used inside a table
- prototype.js is causing chart.js to not work HOT 2
- Array.from doesn't work with some iterables HOT 1
- $F throws an error when missing element
- Prototype is no longer compatible with Vue.js HOT 2
- Future and present of Prototype.js HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prototype.