I've been noticing that if I set a style color to a named color or RGB value it will retain that literal value when retrieved. However, when set to a hex string or HSL string it gets automatically converted to an RGB string instead:
let body = document.querySelector('body');
console.log(body.style.backgroundColor); // ""
body.style.backgroundColor = 'white';
console.log(body.style.backgroundColor); // white
body.style.backgroundColor = 'rgb(255, 0, 0)';
console.log(body.style.backgroundColor); // rgb(255, 0, 0)
body.style.backgroundColor = '#0080ff';
console.log(body.style.backgroundColor); // rgb(0, 128, 255)
body.style.backgroundColor = 'hsl(195, 100%, 50%)';
console.log(body.style.backgroundColor); // rgb(0, 191, 255)
What's the rationale behind this behavior?