aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrandon Aaron <brandon.aaron@gmail.com>2007-03-21 20:10:04 +0000
committerBrandon Aaron <brandon.aaron@gmail.com>2007-03-21 20:10:04 +0000
commit3728a8ac0494de7ccab48bfc69f5d71496ba64c2 (patch)
tree99c9889a48abace374ab376f7fc688e47cef8cec /src
parent36774226dd241ae104e10e8073a0586c50ae59ad (diff)
downloadjquery-3728a8ac0494de7ccab48bfc69f5d71496ba64c2.tar.gz
jquery-3728a8ac0494de7ccab48bfc69f5d71496ba64c2.zip
Fix for #1064 and added tests for setting/getting opacity
Diffstat (limited to 'src')
-rw-r--r--src/jquery/coreTest.js22
-rw-r--r--src/jquery/jquery.js2
2 files changed, 21 insertions, 3 deletions
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index c8dada498..4370e9da8 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -240,7 +240,7 @@ if ( location.protocol != "file:" ) {
}
test("css(String|Hash)", function() {
- expect(8);
+ expect(19);
ok( $('#main').css("display") == 'none', 'Check for css property "display"');
@@ -258,10 +258,19 @@ test("css(String|Hash)", function() {
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');
+
+ $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ $('#foo').css({opacity: n});
+ ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" );
+ $('#foo').css({opacity: parseFloat(n)});
+ ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" );
+ });
+ $('#foo').css({opacity: ''});
+ ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
});
test("css(String, Object)", function() {
- expect(7);
+ expect(18);
ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
$('#foo').css('display', 'none');
ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
@@ -276,6 +285,15 @@ test("css(String, Object)", function() {
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');
+
+ $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ $('#foo').css('opacity', n);
+ ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" );
+ $('#foo').css('opacity', parseFloat(n));
+ ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" );
+ });
+ $('#foo').css('opacity', '');
+ ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
});
test("text()", function() {
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 0c00829f6..0f79216fe 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -1537,7 +1537,7 @@ jQuery.extend({
}
return elem.filter ?
- (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
+ (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : 1;
}
// Certain attributes only work when accessed via the old DOM 0 way