The House narrowly passed a bill to add new restrictions on lawmakers trading stocks after a partisan dispute resulted in a narrower proposal that stops short of an outright ban.