29572: Improve entity decoding for JavaScript

https://core.trac.wordpress.org/ticket/29572