0
@@ -5,6 +5,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
0
rtagName = /<([\w:]+)/,
0
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
0
fcloseTag = function( all, front, tag ) {
0
return rselfClosing.test( tag ) ?
0
@@ -35,7 +36,7 @@ jQuery.fn.extend({
0
if ( jQuery.isFunction(text) ) {
0
return this.each(function(i) {
0
var self = jQuery(this);
0
-
return self.text( text.call(this, i, self.text()) );
0
+
self.text( text.call(this, i, self.text()) );
0
@@ -251,11 +252,18 @@ jQuery.fn.extend({
0
domManip: function( args, table, callback ) {
0
var results, first, value = args[0], scripts = [];
0
+ // We can't cloneNode fragments that contain checked, in WebKit
0
+ if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
0
+ return this.each(function() {
0
+ jQuery(this).domManip( args, table, callback, true );
0
if ( jQuery.isFunction(value) ) {
0
return this.each(function(i) {
0
var self = jQuery(this);
0
args[0] = value.call(this, i, table ? self.html() : undefined);
0
-
return self.domManip( args, table, callback );
0
+
self.domManip( args, table, callback );
0
@@ -326,7 +334,8 @@ function cloneCopyEvent(orig, ret) {
0
function buildFragment( args, nodes, scripts ) {
0
var fragment, cacheable, cacheresults, doc;
0
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
0
+ // webkit does not clone 'checked' attribute of radio inputs on cloneNode, so don't cache if string has a checked
0
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
0
cacheresults = jQuery.fragments[ args[0] ];
Thanks for fixing up my crummy regex and including this, John.
And good call on adding support.checkClone. I hadn't considered that in what I saw as an all-or-nothing decision to be dirty and explicitly check browser.webkit, or always test the regex and be slow.
Hey Michael, Thanks for the patch. Note that I ended up having to change a bunch of things: I couldn't get the test cases to fail so I rewrote them into a failing state. In doing so I ran across another set of problems (buildFragment isn't the only place where a fragment can be cloned, it can also happen in domManip - hence the new block of code there). It ended up being a surprisingly complex problem - especially building support.checkClone - because it turns out this only happens when you clone an already cloned fragment (a strange case, to be sure). Anyway, thanks for your help, I appreciate it!
Ah, you're right. I wrongly committed "cleaned up" tests at the last minute without re-verifying they still failed against unpatched 1.4.0. And I also totally missed domManip. Thanks for not blindly accepting patches from strangers! :)
Not that it's of much consequence now, but I do think Webkit's issue is not related to duplicate clones nor does jQuery require duplicate calls to
cloneNodeto establishsupport.checkClone. I can reproduce Webkit's issue with only a single call tocloneNode. http://michaelmonteleone.net/files/jq14Webkit/Webkitclone.html (Reproducible in Safari 4.0.4 and Chromium nightly).which matches with my original experience in 1.4.0 where there is theoretically only a single clone occurring in the following http://michaelmonteleone.net/files/jq14Webkit/jq140clone.html:
<>>So changing to
jQuery.support.checkClone = fragment.cloneNode(true).lastChild.checked;still seems to do the job.And just to add one more big of Webkit weirdness: Webkit only exhibits this issue when the input has a name attribute.
But yes, I clouded the issue with my broken tests. And I will be sure to help test more while still in pre-release next time. Thank you again for your thoroughness and improvements to the original patch.
That second link without the HTTP 300 inducing trailing colon: http://michaelmonteleone.net/files/jq14Webkit/jq140clone.html