Skip to content

.toRgbString() returns unexpectedly unspaced result #88

Closed
@jhack89

Description

@jhack89

Dear Developers,

color.toRgbString() is supposed to be compatible with the jQuery.css(), however it does not return an easily comparable value.
In fact, jQuery.css("color") returns colors as "rgb(xxx, xxx, xxx)" while .toRgbString() return the same as "rgb(xxx,xxx,xxx)" without spaces! This makes impossible to easily compare colors as strings without workarounds such as $("<div>").css("color", color.toRgbString()).css("color"). This is especially important when comparing miscellaneous CSS proprieties.

Example code where I needed to use the workaround to make things work seamlessly:

$("#element").click(function() {
$(this).animate(
{
   "backgroundColor": "red",
   "width", "+=100"
}, {
    duration: 1000,
    step(val, fx) {
    // some code here
    if( $("<div>").css(fx.prop, fx.end.toString()).css(fx.prop) == check[fx.prop]) { ... }
    /* instead of the expected: 
     * if(fx.end.toString() == check[fx.prop]) { ... }
     */
    // more code here
    }
})
});

It would be great if this little bug could be fixed.
Thank you for your great work,
Warmest Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions