/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/NodeList-manipulate","./query ./_base/lang ./_base/array ./dom-construct ./dom-attr ./NodeList-dom".split(" "),function(m,n,u,q,r){function t(a){for(;a.childNodes[0]&&1==a.childNodes[0].nodeType;)a=a.childNodes[0];return a}function p(a,b){"string"==typeof a?(a=q.toDom(a,b&&b.ownerDocument),11==a.nodeType&&(a=a.childNodes[0])):1==a.nodeType&&a.parentNode&&(a=a.cloneNode(!1));return a}var k=m.NodeList;n.extend(k,{_placeMultiple:function(a,b){for(var c="string"==typeof a||a.nodeType?m(a):
a,d=[],f=0;f<c.length;f++)for(var e=c[f],l=this.length,g=l-1,h;h=this[g];g--)0<f&&(h=this._cloneNode(h),d.unshift(h)),g==l-1?q.place(h,e,b):e.parentNode.insertBefore(h,e),e=h;d.length&&(d.unshift(0),d.unshift(this.length-1),Array.prototype.splice.apply(this,d));return this},innerHTML:function(a){return arguments.length?this.addContent(a,"only"):this[0].innerHTML},text:function(a){if(arguments.length){for(var b=0,c;c=this[b];b++)1==c.nodeType&&r.set(c,"textContent",a);return this}var d="";for(b=0;c=
this[b];b++)d+=r.get(c,"textContent");return d},val:function(a){if(arguments.length){for(var b=n.isArray(a),c=0,d;d=this[c];c++){var f=d.nodeName.toUpperCase(),e=d.type,l=b?a[c]:a;if("SELECT"==f)for(f=d.options,e=0;e<f.length;e++){var g=f[e];g.selected=d.multiple?-1!=u.indexOf(a,g.value):g.value==l}else"checkbox"==e||"radio"==e?d.checked=d.value==l:d.value=l}return this}if((d=this[0])&&1==d.nodeType){a=d.value||"";if("SELECT"==d.nodeName.toUpperCase()&&d.multiple){a=[];f=d.options;for(e=0;e<f.length;e++)g=
f[e],g.selected&&a.push(g.value);a.length||(a=null)}return a}},append:function(a){return this.addContent(a,"last")},appendTo:function(a){return this._placeMultiple(a,"last")},prepend:function(a){return this.addContent(a,"first")},prependTo:function(a){return this._placeMultiple(a,"first")},after:function(a){return this.addContent(a,"after")},insertAfter:function(a){return this._placeMultiple(a,"after")},before:function(a){return this.addContent(a,"before")},insertBefore:function(a){return this._placeMultiple(a,
"before")},remove:k.prototype.orphan,wrap:function(a){if(this[0]){a=p(a,this[0]);for(var b=0,c;c=this[b];b++){var d=this._cloneNode(a);c.parentNode&&c.parentNode.replaceChild(d,c);t(d).appendChild(c)}}return this},wrapAll:function(a){if(this[0]){a=p(a,this[0]);this[0].parentNode.replaceChild(a,this[0]);a=t(a);for(var b=0,c;c=this[b];b++)a.appendChild(c)}return this},wrapInner:function(a){if(this[0]){a=p(a,this[0]);for(var b=0;b<this.length;b++){var c=this._cloneNode(a);this._wrap(n._toArray(this[b].childNodes),
null,this._NodeListCtor).wrapAll(c)}}return this},replaceWith:function(a){a=this._normalize(a,this[0]);for(var b=0,c;c=this[b];b++)this._place(a,c,"before",0<b),c.parentNode.removeChild(c);return this},replaceAll:function(a){a=m(a);for(var b=this._normalize(this,this[0]),c=0,d;d=a[c];c++)this._place(b,d,"before",0<c),d.parentNode.removeChild(d);return this},clone:function(){for(var a=[],b=0;b<this.length;b++)a.push(this._cloneNode(this[b]));return this._wrap(a,this,this._NodeListCtor)}});k.prototype.html||
(k.prototype.html=k.prototype.innerHTML);return k});