JavaScript: Improved condition for outlining

Fixes #526.