Ticket #6910 (closed bug: fixed)

Opened 2 years ago

Last modified 11 months ago

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

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

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

comment:1 Changed 2 years ago by dwt

well, maybe white is a better default.

comment:2 Changed 2 years ago by gnarf

  • Status changed from new to open

comment:3 Changed 2 years ago by gnarf

  • Owner set to gnarf
  • Status changed from open to assigned

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

comment:4 Changed 2 years ago by gnarf

  • Keywords color added

comment:5 Changed 11 months ago by Scott González

  • Status changed from assigned to closed
  • Resolution set to fixed

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.