Fix DOM errors when offline -> online and back