Marcin Wichary:

But there’s a trick [to invert black and white while preserving colors]: do a regular invert and then rotate the hue halfway through. Through the magic of math, this is the same as inverting just L in the HSL space, which means the colors are preserved.

…and, more importantly, [this is] available in CSS as a filter: instead of invert(1), use hue-rotate(180deg) invert(1).