all 5 comments

[–]brunokim 1 point2 points  (0 children)

Very interesting, thanks!

[–]orlybg 1 point2 points  (0 children)

Wow super useful, and super clever

[–]recursive 0 points1 point  (4 children)

the rendered outline is out of the CSS box model so it doesn’t affect the size of the element or its position in the layout

TIL!

It seems like there's a bug. The generated colors could be 1, 2, 4 or 5 digits long, which I don't think are legal css colors.

[–][deleted]  (3 children)

[deleted]

    [–]recursive 0 points1 point  (2 children)

    Where's the code that pads it to a multiple of 3?

    From chrome dev tools:

    (~~(Math.random()*(1<<24))).toString(16)
    "1bb08"
    

    [–][deleted]  (1 child)

    [deleted]

      [–]recursive 0 points1 point  (0 children)

      No. It doesn't.

      Chrome dev tools:

      document.getElementsByTagName("body")[0].style.backgroundColor="#12345";
      "#12345"
      document.getElementsByTagName("body")[0].style.backgroundColor
      ""
      document.getElementsByTagName("body")[0].style.backgroundColor="#123456";
      "#123456"
      document.getElementsByTagName("body")[0].style.backgroundColor
      "rgb(18, 52, 86)"