aboutsummaryrefslogtreecommitdiffstats
path: root/src/manipulation.js
diff options
context:
space:
mode:
authorMichael Monteleone <michael@michaelmonteleone.net>2010-01-25 18:43:33 -0500
committerjeresig <jeresig@gmail.com>2010-01-25 18:43:33 -0500
commitbed759c95ca6d796125653b540e8611dc63b38bb (patch)
treebc8fcc3811466fd18913fd2604586b8c6a96bb04 /src/manipulation.js
parent390186b902c4c1ac13e23754d33ed4d8b3d5fa38 (diff)
downloadjquery-bed759c95ca6d796125653b540e8611dc63b38bb.tar.gz
jquery-bed759c95ca6d796125653b540e8611dc63b38bb.zip
Make sure that checked state is cloned properly. Based upon the patch by Michael, required better test cases and in doing so found more edge cases. Introduced a new check into jQuery.support as a result. Fixes #5929.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r--src/manipulation.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 23463d16e..4d0ffd057 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -5,6 +5,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /<|&\w+;/,
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
fcloseTag = function( all, front, tag ) {
return rselfClosing.test( tag ) ?
all :
@@ -35,7 +36,7 @@ jQuery.fn.extend({
if ( jQuery.isFunction(text) ) {
return this.each(function(i) {
var self = jQuery(this);
- return self.text( text.call(this, i, self.text()) );
+ self.text( text.call(this, i, self.text()) );
});
}
@@ -251,11 +252,18 @@ jQuery.fn.extend({
domManip: function( args, table, callback ) {
var results, first, value = args[0], scripts = [];
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
+ return this.each(function() {
+ jQuery(this).domManip( args, table, callback, true );
+ });
+ }
+
if ( jQuery.isFunction(value) ) {
return this.each(function(i) {
var self = jQuery(this);
args[0] = value.call(this, i, table ? self.html() : undefined);
- return self.domManip( args, table, callback );
+ self.domManip( args, table, callback );
});
}
@@ -326,7 +334,8 @@ function cloneCopyEvent(orig, ret) {
function buildFragment( args, nodes, scripts ) {
var fragment, cacheable, cacheresults, doc;
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ // webkit does not clone 'checked' attribute of radio inputs on cloneNode, so don't cache if string has a checked
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
cacheable = true;
cacheresults = jQuery.fragments[ args[0] ];
if ( cacheresults ) {