fixed potential bug with null "this" parameter in a JavaScript function apply