-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
Summary:
import Tinycolor from 'npm:tinycolor2';
let invalidColor = new Tinycolor('');
let clonedColor = invalidColor.clone();
let shouldBeTrue = invalidColor.isValid() === clonedColor.isValid();
// however: shouldBeTrue === false!When an invalid color is cloned as demonstrated, Tinycolor returns a new color using the other color's string representation (tinycolor.js#L213). However, since clone() does not check the subject's validity and toString() ends up outputting an RGB hex-string using the default rgb-values - again, without first checking the object's validity -, the result is typically a valid #000000 color.
While it is acceptable for clones to represent the same state while not being identical internally, the validity of the color object is very much an important part of it's state and should be preserved in clones.
Metadata
Metadata
Assignees
Labels
No labels