Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions hsp/rt/cptwrapper.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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