JS: Check valid textbuffer. Fixed #1105