fix bug in JS compiler related to history states/regions