X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjquery%2Fjquery.js;h=76f0f0e021518b51dec5c5ea4809afe948be6cef;hb=40b55adf5c22542985c3f7fc2717df9604a3d973;hp=686c20d7bfd69d4b78886792a88aa2bd41ac4ea6;hpb=6f7cd669597cbcf026886074fb31963fe767e2b3;p=jquery.git
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 686c20d..76f0f0e 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) {
@@ -539,7 +543,7 @@ jQuery.fn = jQuery.prototype = {
* $('#floatTest').css({cssFloat: 'left'});
* ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
* $('#floatTest').css({'float': 'right'});
- * ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
+ * ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
* $('#floatTest').css({'font-size': '30px'});
* ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
*
@@ -568,7 +572,7 @@ jQuery.fn = jQuery.prototype = {
* $('#floatTest').css('cssFloat', 'right');
* ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
* $('#floatTest').css('float', 'left');
- * ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
+ * ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
* $('#floatTest').css('font-size', '20px');
* ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
*
@@ -701,6 +705,7 @@ jQuery.fn = jQuery.prototype = {
* @test var defaultText = 'Try them out:'
* var result = $('#first').append('buga');
* ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
+ * ok( $('#select3').append('').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
*
* @name append
* @type jQuery
@@ -764,6 +769,7 @@ jQuery.fn = jQuery.prototype = {
* @test var defaultText = 'Try them out:'
* var result = $('#first').prepend('buga');
* ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
+ * ok( $('#select3').prepend('').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
*
* @name prepend
* @type jQuery
@@ -1473,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" )
@@ -1536,44 +1544,40 @@ 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 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;
- var table = "";
-
- if ( !a[i].indexOf("" + a[i] + "";
- } else if ( !a[i].indexOf("
" + a[i] + "";
- } else if ( !a[i].indexOf("
" + a[i] + "
";
- }
-
- 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;
- }
-
+ // Have to loop through the childNodes here to
+ // prevent a Safari crash with text nodes and /n characters
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()) );
+ }
+ else 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;
},
@@ -1877,7 +1881,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
@@ -2290,16 +2295,26 @@ jQuery.extend({
},
fix: function(event) {
- if ( event ) {
- event.preventDefault = function() {
- this.returnValue = false;
- };
-
- event.stopPropagation = function() {
- this.cancelBubble = true;
- };
+ // check IE
+ if(jQuery.browser.msie) {
+ // get real event from window.event
+ event = window.event;
+ // fix target property
+ event.target = event.srcElement;
+ // check safari and if target is a textnode
+ } else if(jQuery.browser.safari && event.target.nodeType == 3) {
+ // target is readonly, clone the event object
+ event = jQuery.extend({}, event);
+ // get parentnode from textnode
+ event.target = event.target.parentNode;
}
-
+ // fix preventDefault and stopPropagation
+ event.preventDefault = function() {
+ this.returnValue = false;
+ };
+ event.stopPropagation = function() {
+ this.cancelBubble = true;
+ };
return event;
}
@@ -3081,7 +3096,7 @@ jQuery.macros = {
*
* It only returns the immediately previous sibling, not all previous siblings.
*
- * @example $("p").previous(".selected")
+ * @example $("p").prev(".selected")
* @before