Fixed it by setting style.cssText instead of setAttribute