X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=3816296a81107268ec17fb97eb3b4aac25ef2e51;hb=4bcb578c794acd913ec1f42793ce4b1a7388025c;hp=9768eee002afede1e12198546b851dafc7c0c1e7;hpb=14b09024cbe39bc16200448170ccbd183e3a9ec2;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 9768eee..3816296 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -449,6 +449,10 @@ jQuery.fn = jQuery.prototype = { * ok( document.getElementById('check2').checked == true, 'Set checked attribute' ); * $("#check2").attr('checked', false); * ok( document.getElementById('check2').checked == false, 'Set checked attribute' ); + * $("#text1").attr('readonly', true); + * ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' ); + * $("#text1").attr('readonly', false); + * ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' ); * * @test stop(); * $.get('data/dashboard.xml', function(xml) { @@ -1475,9 +1479,11 @@ jQuery.extend({ oHeight = e.offsetHeight; oWidth = e.offsetWidth; } else { - e = jQuery(e.cloneNode(true)).css({ - visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" - }).appendTo(e.parentNode)[0]; + e = jQuery(e.cloneNode(true)) + .find(":radio").removeAttr("checked").end() + .css({ + visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" + }).appendTo(e.parentNode)[0]; var parPos = jQuery.css(e.parentNode,"position"); if ( parPos == "" || parPos == "static" ) @@ -1538,47 +1544,37 @@ jQuery.extend({ return ret; }, - + clean: function(a) { var r = []; for ( var i = 0; i < a.length; i++ ) { - if ( a[i].constructor == String ) { - // trim whitespace, otherwise indexOf won't work as expected - a[i] = jQuery.trim(a[i]); - - var table = ""; - - if ( !a[i].indexOf(""; - } else if ( !a[i].indexOf(""; - } else if ( !a[i].indexOf(""; - } else if ( !a[i].indexOf(""; - } - - var div = document.createElement("div"); - div.innerHTML = a[i]; - - if ( table ) { - div = div.firstChild; - if ( table != "thead" ) div = div.firstChild; - if ( table == "td" ) div = div.firstChild; - } + var arg = a[i]; + if ( arg.constructor == String ) { // Convert html string into DOM nodes + // Trim whitespace, otherwise indexOf won't work as expected + var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""]; + + if ( !s.indexOf("", ""]; + else if ( !s.indexOf("", ""]; + else if ( !s.indexOf("", ""]; // tbody auto-inserted + else if ( !s.indexOf("", ""]; + + // Go to html and back, then peel off extra wrappers + div.innerHTML = wrap[1] + s + wrap[2]; + while ( wrap[0]-- ) div = div.firstChild; + arg = div.childNodes; + } - for ( var j = 0; j < div.childNodes.length; j++ ) - r.push( div.childNodes[j] ); - } else if ( a[i].jquery || a[i].length && !a[i].nodeType ) - for ( var k = 0; k < a[i].length; k++ ) - r.push( a[i][k] ); - else if ( a[i] !== null ) - r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) ); + if ( arg.length != undefined && !arg.nodeType ) // Handles Array, jQuery, DOM NodeList collections + for ( var n = 0; n < arg.length; n++ ) + r.push(arg[n]); + else + r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) ); } + return r; }, @@ -1882,7 +1878,8 @@ jQuery.extend({ className: "className", value: "value", disabled: "disabled", - checked: "checked" + checked: "checked", + readonly: "readOnly" }; // IE actually uses filters for opacity ... elem is actually elem.style