Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
fix ordering of array not being preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
0x8890 committed Nov 23, 2015
1 parent c4f4966 commit fe62be3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ On initialization, Simulacra.js removes bound elements from the document and rep

## Caveats

The DOM will update if there is an assignment on the object, since it uses a property setter under the hood. This means that using the `delete` keyword will not trigger a DOM update. Also, arrays need to be assigned after a mutation, even if it is mutated in place.
The DOM will update if there is an assignment on the object, since it uses a property setter under the hood. This means that using the `delete` keyword will not trigger a DOM update. Also, arrays need to be assigned after a mutation, even if it is mutated in place. This is a conscious decision based on performance, replacing the prototype of an object causes performance problems in every JavaScript engine.


## Under the Hood
Expand Down
9 changes: 4 additions & 5 deletions lib/define_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ function defineProperties (obj, def) {
if (mount) {
node = branch.node.cloneNode(true)
node = mount(node, value, previousValue, i) || node
activeNodes[i] = parentNode.insertBefore(node, branch.marker)
continue
}

if (definition) {
else if (definition) {
node = processNodes(branch.node.cloneNode(true), definition)
defineProperties(value, definition)
activeNodes[i] = parentNode.insertBefore(node, branch.marker)
continue
}

activeNodes[i] = parentNode.insertBefore(node,
activeNodes[i + 1] || branch.marker)
}

// Reset length to current values.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simulacra",
"description": "One-way data binding for web applications.",
"version": "0.0.6",
"version": "0.0.7",
"license": "MIT",
"author": {
"email": "0x8890@airmail.cc",
Expand Down

0 comments on commit fe62be3

Please sign in to comment.