Avoid expensive for..in loops involving CMaps

This is much the same as #4804, which was abandoned.
According to micro-benchmarks, `in` is two orders of magnitude slower in modern browsers; see e.g. http://jsperf.com/in-vs-not-undefined.