fix: IndexSizeError: DOM Exception 1

fix error “IndexSizeError: DOM Exception 1: Index or size was negative,
or greater than the allowed value”