Opened 9 years ago

Closed 7 years ago

#6910 closed bug (fixed)

Trying to animate the background color of a document fragment can easily fail

Reported by: dwt Owned by: Corey Frang
Priority: minor Milestone: 1.9.0
Component: ui.effects.* (individual effect) Version: 1.8.8
Keywords: color Cc:
Blocked by: Blocking:

Description

I discovered this as I wanted to run unit-tests on document-fragments to avoid having the browser trying to actually render them. (For speed).

The problem is that the method getColor (in the effects package) will return undefined as / if the document fragment root does no color.

Bad bad library. :)

Here's the problematic code

function getColor(elem, attr) {

var color;

do {

color = $.curCSS(elem, attr);

Keep going until we find an element that has color, or we hit the body

if ( color != && color != 'transparent'
$.nodeName(elem, "body") )

break;

attr = "backgroundColor";

} while ( elem = elem.parentNode );

return getRGB(color);

};

I think that this needs another check which defaults to 'transparent' if no color cold be found (or otherwise defaults to something that is valid for that browser).

Change History (5)

comment:1 Changed 9 years ago by dwt

well, maybe white is a better default.

comment:2 Changed 9 years ago by Corey Frang

Status: newopen

comment:3 Changed 9 years ago by Corey Frang

Owner: set to Corey Frang
Status: openassigned

The rewrite of jquery.color is going to fix this.

comment:4 Changed 9 years ago by Corey Frang

Keywords: color added

comment:5 Changed 7 years ago by Scott González

Resolution: fixed
Status: assignedclosed

Upgrade to jquery-color 2.0pre. Fixes #6910 - Trying to animate the background color of a document fragment can easily fail. Fixes #5215 - Effects color: Add support for rgba animations. Fixes #4372 - Animate backgroundColor to 'transparent'. Fixes #5393 - getColor reports inaccurate color for transparent elements in Webkit. Fixes #3806 - Feature request: expose getRGB and getColor.

Changeset: 13d560b8f05a8eedbf28851824fe639a254f9fd0

Note: See TracTickets for help on using tickets.