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

Commit

Permalink
Merge pull request #2 from wickedest/master
Browse files Browse the repository at this point in the history
Fixed frozen data object
  • Loading branch information
Leo committed Jul 31, 2015
2 parents 3d82a96 + 8089f6e commit 10972c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Makefile
@@ -1,3 +1,4 @@
TESTS = test/index.js

build: components index.js
@component build --dev
Expand All @@ -8,4 +9,9 @@ components: component.json
clean:
rm -fr build components template.js

.PHONY: clean
test:
@./node_modules/.bin/mocha \
--growl \
$(TESTS)

.PHONY: test clean
1 change: 0 additions & 1 deletion index.js
Expand Up @@ -390,7 +390,6 @@ o.data = function () {
this._data[k] = obj[k];
}

Object.freeze(obj);
this.emit("data change",this,obj);
var root = this.root;
if(root !== this){
Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"description": "tree node",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "make test"
},
"repository": {
"type": "git",
Expand All @@ -28,5 +28,7 @@
"dependencies": {
"emitter-component": "~1.1.1"
},
"devDependencies": {}
"devDependencies": {
"mocha": "*"
}
}
12 changes: 11 additions & 1 deletion test/index.js
Expand Up @@ -199,8 +199,18 @@ describe("Node",function(){

node.data({age:12});
assert(node.data("name") === "leo" && node.data("age") === 12);

node.data({age:13});
assert(node.data("name") === "leo" && node.data("age") === 13);
assert(node.data() === node._data);

var node2 = new Node();
node2.data({age:12});
var data = node2.data();
data.age = data.age + 1;
node2.data(data);
data.age = data.age + 1;
node2.data(data);
assert(data.age === 14);
});

it("#json",function(){
Expand Down

0 comments on commit 10972c4

Please sign in to comment.