Skip to content

Commit

Permalink
Merge ccb5abc into 1af5ebf
Browse files Browse the repository at this point in the history
  • Loading branch information
marclaval committed Sep 2, 2014
2 parents 1af5ebf + ccb5abc commit 6d7f551
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
15 changes: 13 additions & 2 deletions hsp/rt/cptwrapper.js
Expand Up @@ -211,8 +211,8 @@ var CptWrapper = klass({
}
if (att.type === "callback") {
// create an even callback function
this.createEventFunction(k.slice(2));
cpt[k].isEmpty=(iAtt===undefined);
var isEmpty = !this.createEventFunction(k.slice(2));
cpt[k].isEmpty = isEmpty;
continue;
} else if (att.type === "template") {
v=null;
Expand Down Expand Up @@ -268,6 +268,17 @@ var CptWrapper = klass({
self.nodeInstance.onEvent(evtData);
}
};
if (this.nodeInstance) {
var evh = this.nodeInstance.evtHandlers;
if (evh) {
for (var i = 0; i < evh.length; i++) {
if (evh[i].evtType === evtType) {
return true;
}
}
}
}
return false;
},

/**
Expand Down
17 changes: 16 additions & 1 deletion test/rt/cptwrapper.spec.hsp
Expand Up @@ -192,6 +192,9 @@ describe("Component Nodes", function () {
expect(c.value).to.equal(0);
expect(c.isValid).to.equal(false);

//Issue #33
expect(c.onbeforereset.isEmpty).to.be.ok();

cw.$dispose();
expect(cw.cpt).to.equal(null);
expect(c["+json:observers"]).to.equal(undefined);
Expand Down Expand Up @@ -334,12 +337,24 @@ it("tests a component inside another template", function() {

expect(resetCount).to.equal(1); //validate that "onbeforereset" callback has been called
expect(lastEvtType).to.equal("beforereset");
expect(isBrCbEmpty).to.equal(true);
expect(isBrCbEmpty).to.equal(false);
expect(lastResetArg).to.equal(123);
expect(lastEvtType2).to.equal("afterreset");
expect(lastEvtOldValue2).to.equal(42);
});

it("tests if callback is not empty (issue #33)", function() {
isBrCbEmpty=false;
var d={value:'42'};
var n=test(d);
var cptButton=n.node.childNodes[3];

fireEvent("click",cptButton);
hsp.refresh();

expect(isBrCbEmpty).to.equal(false);
});

it("tests if callback is empty", function() {
isBrCbEmpty=false;
var d={value:'42'};
Expand Down

0 comments on commit 6d7f551

Please sign in to comment.