From c9a566d440a4d8f7b59c6cacfc998ada9602e411 Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Sat, 9 Nov 2024 03:21:07 +1100 Subject: [PATCH] Reference nodes not elements --- factory.js | 6 +++--- package.json | 2 +- whatsnew.md | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/factory.js b/factory.js index 43b2e51..5e451d5 100644 --- a/factory.js +++ b/factory.js @@ -339,8 +339,8 @@ export function replace_content(target, template) { //cases: the first N matching DOM elements will not be removed. TODO: Also check for the _last_ N //matching elements, which will allow any single block of deletions/insertions. let keep = 0; - while (keep < content.length && content[keep] instanceof Node && target.children[keep] === content[keep]) ++keep; - while (target.children.length > keep) target.removeChild(target.lastChild); + while (keep < content.length && content[keep] instanceof Node && target.childNodes[keep] === content[keep]) ++keep; + while (target.childNodes.length > keep) target.removeChild(target.lastChild); append_child(target, content.slice(keep)); return target; } @@ -369,7 +369,7 @@ function autobind(obj, prop) { choc = new Proxy(choc, {get: autobind}); lindt = new Proxy(lindt, {get: autobind}); -choc.__version__ = "1.9.0"; +choc.__version__ = "1.9.1"; //For modules, make the main entry-point easily available. export default choc; diff --git a/package.json b/package.json index 23a7eb5..4a1ba92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chocfactory", - "version": "1.9.0", + "version": "1.9.1", "description": "Simple JS front end library", "main": "factory.js", "scripts": { diff --git a/whatsnew.md b/whatsnew.md index 1aa1cb8..72c95b0 100644 --- a/whatsnew.md +++ b/whatsnew.md @@ -1,5 +1,8 @@ ## Chocolate Factory version history +### v1.9.1 +* Oopsie, miscalculated the children... + ### v1.9.0 * In Lindt mode, appending new children to a DOM element will not cause existing elements to be removed and reinserted unnecessarily.