After setting either strokeStyle or fillStyle to a 9-character hex code, e.g.
ctx.fillStyle = '#ffaa00bb'
The draw works as-expected (uses the alpha channel appropriately), but reading the value will only return a 7-character hex code with the alpha value removed, e.g.
console.log(ctx.fillStyle)
outputs '#ffaa00'
I tested this in Firefox and Chrome. Not sure why it’s happening, any insight would be appreciated.
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#ffaa00bb";
console.log(ctx.fillStyle);
1