Sha256: a506eccc9534098db1f445c63c361475962dfd8185bfe2626f45d89cbafac44c
Contents?: true
Size: 1.25 KB
Versions: 24
Compression:
Stored size: 1.25 KB
Contents
//>>excludeStart("exclude", pragmas.exclude); define([ "shoestring" ], function(){ //>>excludeEnd("exclude"); /** * Replace each element in the current set with that argument HTML string or HTMLElement. * * @param {string|HTMLElement} fragment The value to assign. * @return shoestring * @this shoestring */ shoestring.fn.replaceWith = function( fragment ){ if( typeof( fragment ) === "string" ){ fragment = shoestring( fragment ); } var ret = []; if( fragment.length > 1 ){ fragment = fragment.reverse(); } this.each(function( i ){ var clone = this.cloneNode( true ), insertEl; ret.push( clone ); // If there is no parentNode, this is pointless, drop it. if( !this.parentNode ){ return; } if( fragment.length === 1 ){ insertEl = i > 0 ? fragment[ 0 ].cloneNode( true ) : fragment[ 0 ]; this.parentNode.replaceChild( insertEl, this ); } else { for( var j = 0, jl = fragment.length; j < jl; j++ ){ insertEl = i > 0 ? fragment[ j ].cloneNode( true ) : fragment[ j ]; this.parentNode.insertBefore( insertEl, this.nextSibling ); } this.parentNode.removeChild( this ); } }); return shoestring( ret ); }; //>>excludeStart("exclude", pragmas.exclude); }); //>>excludeEnd("exclude");
Version data entries
24 entries across 24 versions & 1 rubygems