I had defined a variable as null, when it was probably more appropriate to define it as undefined.