diff --git a/src/zepto.js b/src/zepto.js index 696910884..9131f2bdc 100644 --- a/src/zepto.js +++ b/src/zepto.js @@ -849,8 +849,17 @@ var Zepto = (function() { $.fn[operator] = function(){ // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings var argType, nodes = $.map(arguments, function(arg) { + var arr = [] argType = type(arg) - return argType == "object" || argType == "array" || arg == null ? + if (argType == "array") { + arg.forEach(function(el) { + if (el.nodeType !== undefined) return arr.push(el) + else if ($.zepto.isZ(el)) return arr = arr.concat(el.get()) + arr = arr.concat(zepto.fragment(el)) + }) + return arr + } + return argType == "object" || arg == null ? arg : zepto.fragment(arg) }), parent, copyByClone = this.length > 1 diff --git a/test/zepto.html b/test/zepto.html index e1d59347e..e781e7d09 100644 --- a/test/zepto.html +++ b/test/zepto.html @@ -2186,6 +2186,19 @@

Zepto Core unit tests

$.map(el.children(), function(c){ return $(c).text() }).join(' ')) }, + testAppendWithArrayParams: function(t){ + var zpElement = $('five') + var multElements = $('sixseven') + var node = document.createElement('b') + node.appendChild(document.createTextNode('four')) + + // append elements on this array + var arrElements = ['onetwo', 'three', node, zpElement, multElements ] + var el = $('
') + el.append(arrElements) + t.assertEqual('onetwothreefourfivesixseven', el.html()) + }, + testAppendToPrependTo: function(t){ // testing with Zepto object function div(contents){