sourcebitsllc / chocolatechip-ui

Mobile Web App Framework
www.chocolatechip-ui.com
MIT License
616 stars 88 forks source link

append/inserting an array of nodes cause only the first node to be inserted #21

Closed extrakun closed 10 years ago

extrakun commented 10 years ago

Code:

Start with an empty div (and only div in the page)

var a = $.make('<p>hello world</p>    <p>hello word again!</p>')
$('div").insert(a); // or $(div).append(a);

Only the first node will be added to the div

Did some tracing,think it's related to line 758 in chocolatechip-3.0.6.js:

            this.each(function(node, idx) {
               __insert(node, cnt[idx], position);
            });

the this in the line refers to that of the container being inserted to, rather than the array of nodes that is being inserted. Tried changing this to cnt but no luck, got an error "trying to insert a node where it doesn't belong"

sourcebits-robertbiggs commented 10 years ago

Thanks, that is a serious bug. I'll give that high priority today.

sourcebits-robertbiggs commented 10 years ago

This has been addressed in commit c0ad390624 The [].insert method now properly injects arrays of elements into the target elements.