Thanks for this library! I am working on a tool, that allows users to enter L*a*b* values in the browser. When passing the values directly from the input DOM elements, they are passed as Strings. This can cause some values to get concatenated instead of added together.
Example Code
var l1 = document.getElementById('someID').value;
var a1 = document.getElementById('someID').value;
var b2 = document.getElementById('someID').value;
var color1 = {L: l, A: a, B: b};
DeltaE = new dE00(color1, color2);
Result
When a new dE00 object is created this.LBar, this.aPrime1, and this.aPrime2 will concatenate the two numbers in their respective formulas resulting in them being set to NaN. This will cause dE00.getDeltaE() to also return NaN.
Thanks for this library! I am working on a tool, that allows users to enter L*a*b* values in the browser. When passing the values directly from the input DOM elements, they are passed as Strings. This can cause some values to get concatenated instead of added together.
Example Code
Result
When a new
dE00
object is createdthis.LBar
,this.aPrime1
, andthis.aPrime2
will concatenate the two numbers in their respective formulas resulting in them being set toNaN
. This will causedE00.getDeltaE()
to also returnNaN
.Lines where concatenation occurs:
Fix: Apply
parseFloat()
to values ofx1
andx2