From the highlights shown the referee was rubbish and this decision was one of a few poor ones.
Perhaps he had already made his mind up from a previous game where it seemed James had dived.
Unfortunately for James, his pace and his slight frame make it look like there is simulation and decisions will sometimes go against him.
Very much doubt Mo Salah would have been booked there though and it seems you have to earn the right to get refereeing decisions.