Skip to content

Commit

Permalink
Fix for override of appendTo and related methods, corresponding to re…
Browse files Browse the repository at this point in the history
…late fix in jQuery 1.4.2, for ticket #6227.

Also revert the change for preventing options.data overriding data. See comment in previous commit.
  • Loading branch information
BorisMoore committed Nov 25, 2010
1 parent 3fd23ad commit c6a94bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion demos/samplesCore/parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script>
$(function(){
$("#tmplPeople")
.tmpl( people, {allCities: allCities} )
.tmpl( people )
.appendTo(".peopleTable");
});

Expand Down
16 changes: 6 additions & 10 deletions jquery.tmpl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* jQuery Templates Plugin preBeta1.0.1
* http://github.com/jquery/jquery-tmpl
* Requires jQuery 1.4.2
*
* Copyright Software Freedom Conservancy, Inc.
* Dual licensed under the MIT or GPL Version 2 licenses.
Expand All @@ -27,7 +28,7 @@
update: tiUpdate
};
if ( options ) {
jQuery.extend( newItem, options, { nodes: [], parent: parentItem, data: newItem.data });
jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
}
if ( fn ) {
// Build the hierarchical content to be used during insertion into DOM
Expand Down Expand Up @@ -60,7 +61,7 @@
for ( i = 0, l = insert.length; i < l; i++ ) {
cloneIndex = i;
elems = (i > 0 ? this.clone(true) : this).get();
jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
jQuery( insert[i] )[ original ]( elems );
ret = ret.concat( elems );
}
cloneIndex = 0;
Expand Down Expand Up @@ -91,14 +92,9 @@
},

domManip: function( args, table, callback, options ) {
// This appears to be a bug in the appendTo, etc. implementation
// it should be doing .call() instead of .apply(). See #6227
if ( args[0] && args[0].nodeType ) {
var dmArgs = jQuery.makeArray( arguments ), argsLength = args.length, i = 0, tmplItem;
while ( i < argsLength && !(tmplItem = jQuery.data( args[i++], "tmplItem" ))) {}
if ( argsLength > 1 ) {
dmArgs[0] = [jQuery.makeArray( args )];
}
if ( args[0] && jQuery.isArray( args[0] )) {
var dmArgs = jQuery.makeArray( arguments ), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
while ( i < elemsLength && !(tmplItem = jQuery.data( elems[i++], "tmplItem" ))) {}
if ( tmplItem && cloneIndex ) {
dmArgs[2] = function( fragClone ) {
// Handler called by oldManip when rendered template has been inserted into DOM.
Expand Down

0 comments on commit c6a94bb

Please sign in to comment.