John Tavares had a goal and two assists as the Toronto Maple Leafs held on to beat the Detroit Red Wings 5-4.