I just wanted to comment to help anyone who had the same problem as me. This particular example only applies to things in a “read” mode. So, for my situation I was trying to make things change color when it was in “readonly” which means the examples all failed.
I just needed to change this bit:
field.mode == ‘read’
to
field.mode == ‘readonly’
and my highlighting worked.
I am sure this is a stupid problem, but it caught me out for an hour and I wanted to save someone else an hour.