Skip to content

Commit

Permalink
Reference nodes not elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Nov 8, 2024
1 parent c5becd1 commit c9a566d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chocfactory",
"version": "1.9.0",
"version": "1.9.1",
"description": "Simple JS front end library",
"main": "factory.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions whatsnew.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit c9a566d

Please sign in to comment.