Skip to content

Commit

Permalink
[dev] fix bug on parts length
Browse files Browse the repository at this point in the history
  • Loading branch information
enzoaicardi committed Jun 2, 2024
1 parent c8dc123 commit a1fccbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/directives/for.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const reconcile = (context, element, prevList, nextList, key) => {

// REMOVE ELEMENTS
if (gap < 0) {
removeParts(element, index);
removeParts(element, index, index - gap);
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/directives/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ export const updatePart = (template, index, value) => {
* remove a DOM part from the DOM and disconnect it
* @param {HTMLTemplateElement} template
* @param {number} index
* @param {number} length
*/
export const removeParts = (template, index) => {
export const removeParts = (template, index, length) => {
/** @type {Array<VIF.Part>} */
const parts = template.templateParts;

Expand All @@ -133,7 +134,7 @@ export const removeParts = (template, index) => {
const head = parts[index].flag;

// remove all the nodes between head and tail for all parts
while (index++ < parts.length - 1) {
while (index++ < length) {
// get the current comparison node
let currentNode = nextSiblingOf(head);
// retrieve the current part tail
Expand Down

0 comments on commit a1fccbd

Please sign in to comment.