work on #329 and ceylon/ceylon-js#343
changes derived from ceylon/ceylon-js#343
fix #329 (for js)