diff --git a/CHANGELOG.md b/CHANGELOG.md index 609c082..4492c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## [3.0.5] - 2024-06-05 + +## Fixed + +- Fixed clear collection ([#367](https://github.com/reyesoft/ngx-jsonapi/pull/367)) + ## [3.0.4] - 2024-06-05 ## Fixed -- Fixed document-collection remove collection elements ([#365](https://github.com/reyesoft/ngx-jsonapi/pull/365)) +- Fixed document-collection remove collection elements ([#366](https://github.com/reyesoft/ngx-jsonapi/pull/366)) ## [3.0.3] - 2024-06-05 diff --git a/src/document-collection.ts b/src/document-collection.ts index 2701c8b..86d5ddd 100644 --- a/src/document-collection.ts +++ b/src/document-collection.ts @@ -49,7 +49,20 @@ export class RelatedDocumentCollection extends Do // convert and add new dataresoures to final collection let new_ids = {}; - this.data.splice(0, this.data.length); + try { + // Intenta vaciar el arreglo estableciendo length a 0 + this.data.length = 0; + } catch (error) { + // Intenta usar métodos de mutación + try { + while (this.data.length) { + this.data.shift(); // shift elimina el primer elemento + } + } catch (shiftError) { + // Crea una copia del arreglo vacío y reemplaza el original + this.data = []; + } + } this.builded = data_collection.data && data_collection.data.length === 0; for (let dataresource of data_collection.data) { try { diff --git a/src/package.json b/src/package.json index 195123c..9f04eef 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "ngx-jsonapi", - "version": "3.0.4", + "version": "3.0.5", "description": "JSON API library for Angular", "module": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js", "es2015": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.js",