Skip to content

Commit

Permalink
Fixes jQueryUI #8914: Avoid cssHook blending in non-rgba browsers whe…
Browse files Browse the repository at this point in the history
…n the value is "transparent"
  • Loading branch information
mikesherov committed Jan 3, 2013
1 parent b05afc5 commit aeeff3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jquery.color.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ color.hook = function( hook ) {
var parsed, curElem,
backgroundColor = "";

if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
value = color( parsed || value );
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
Expand Down
10 changes: 10 additions & 0 deletions test/unit/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,16 @@ test( "Setting CSS to empty string / inherit", function() {
ok( el[0].style.color === "" || el[0].style.color === "inherit", "Setting CSS to inherit didn't throw error" );
});

test( "Setting CSS to transparent", function() {
expect( 1 );

var parentEl = jQuery("<div></div>").appendTo("body").css({ backgroundColor: "blue" }),
el = jQuery("<div></div>").appendTo( parentEl );

el.css( "backgroundColor", "transparent" );
equal( jQuery.Color( el[ 0 ].style.backgroundColor ).alpha(), 0, "CSS was set to transparent" );
});

test( "jQuery.Color.hook() - Create new hooks for color properties", 2, function() {

// these shouldn't be there, but just in case....
Expand Down

0 comments on commit aeeff3d

Please sign in to comment.