soyjavi / QuoJS

Micro #JavaScript Library for Mobile Devices
MIT License
2.07k stars 236 forks source link

Append with multiple nodes #20

Closed floriandiud closed 11 years ago

floriandiud commented 12 years ago
<div id="elem"></div>

if you do:

$$('#elem').prepend('<p>1</p><p>2</p><p>3</p>');
<div id="elem"><p>1</p><p>2</p><p>3</p></div>

It works well, but with append:

$$('#elem').append('<p>1</p><p>2</p><p>3</p>');

It only appends the first element

<div id="elem"><p>1</p></div>
floriandiud commented 12 years ago

I guess it's because of "div.firstChild":

    $$.fn.append = function(value) {
        return this.each(function() {
            if ($$.toType(value) === 'string') {
                if (value) {
                    var div = document.createElement();
                    div.innerHTML = value;
                    this.appendChild(div.firstChild);
                }
            } else {
                this.insertBefore(value);
            }
        });
    };
soyjavi commented 11 years ago

Thanks, I'll implement in version 2.3