Fix JS errors when parent does not exist yet