array.insert throws length-exceeded event - fixes #314

This commit is contained in:
Kevin Jahns
2021-06-24 16:50:25 +02:00
parent 89c5541ee6
commit 311dd50f1b
4 changed files with 51 additions and 3 deletions

View File

@@ -679,6 +679,8 @@ export const typeListInsertGenericsAfter = (transaction, parent, referenceItem,
packJsonContent()
}
const lengthExceeded = error.create('Length exceeded!')
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
@@ -689,6 +691,9 @@ export const typeListInsertGenericsAfter = (transaction, parent, referenceItem,
* @function
*/
export const typeListInsertGenerics = (transaction, parent, index, content) => {
if (index > parent._length) {
throw lengthExceeded
}
if (index === 0) {
if (parent._searchMarker) {
updateMarkerChanges(parent._searchMarker, index, content.length)
@@ -766,7 +771,7 @@ export const typeListDelete = (transaction, parent, index, length) => {
n = n.right
}
if (length > 0) {
throw error.create('array length exceeded')
throw lengthExceeded
}
if (parent._searchMarker) {
updateMarkerChanges(parent._searchMarker, startIndex, -startLength + length /* in case we remove the above exception */)

View File

@@ -169,7 +169,7 @@ export class YXmlElement extends YXmlFragment {
*
* @public
*/
hasAttribute (attributeName) {
hasAttribute (attributeName) {
return /** @type {any} */ (typeMapHas(this, attributeName))
}