Fix JS component element selection logic