Skip to content
This repository was archived by the owner on Jan 25, 2021. It is now read-only.
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
2 changes: 1 addition & 1 deletion build/fragments/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4-beta
0.1.5-beta
14 changes: 10 additions & 4 deletions build/output/intravenous-latest.debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Intravenous JavaScript library v0.1.4-beta
// Intravenous JavaScript library v0.1.5-beta
// (c) Roy Jacobs
// License: MIT (http://www.opensource.org/licenses/mit-license.php)

Expand Down Expand Up @@ -30,7 +30,7 @@ var exportSymbol = function(path, object) {
var exportProperty = function(owner, publicName, object) {
owner[publicName] = object;
};
intravenous.version = "0.1.4-beta";
intravenous.version = "0.1.5-beta";
exportSymbol('version', intravenous.version);
(function() {
"use strict";
Expand Down Expand Up @@ -87,7 +87,7 @@ exportSymbol('version', intravenous.version);
cacheItem.tag = this.tag;

this.refCounts[cacheItem.tag] = this.refCounts[cacheItem.tag] || {};
this.refCounts[cacheItem.tag][cacheItem.registration.key] = this.refCounts[cacheItem.tag][cacheItem.registration.key]++ || 1;
this.refCounts[cacheItem.tag][cacheItem.registration.key] = this.refCounts[cacheItem.tag][cacheItem.registration.key]+1 || 1;
},

release: function(cacheItem) {
Expand Down Expand Up @@ -128,7 +128,7 @@ exportSymbol('version', intravenous.version);

set: function(cacheItem) {
this.cache.push(cacheItem);
this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]++ || 1;
this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]+1 || 1;
},

release: function(cacheItem) {
Expand All @@ -155,6 +155,7 @@ exportSymbol('version', intravenous.version);
},

release: function(cacheItem) {
delete this.cache[cacheItem];
return true;
},

Expand Down Expand Up @@ -425,6 +426,11 @@ exportSymbol('version', intravenous.version);
}
}
}

if (this.parent) {
var index = this.parent.children.indexOf(this);
this.parent.children.splice(index, 1);
}
return true;
},

Expand Down
20 changes: 10 additions & 10 deletions build/output/intravenous-latest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions spec/spec/factorySpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("A factory", function() {

this.b = function(aFactory) {
var _this = this;
this.aFactory = aFactory;
this.a = aFactory.get("extraParameter");
this.a2 = aFactory.use("dependency", "d2").get("extraParameter");

Expand Down Expand Up @@ -71,6 +72,11 @@ describe("A factory", function() {
it("should not have disposed the instance", function() {
expect(this.disposalCount.b).toBeUndefined();
});

it("should release the first container", function() {
expect(this.retrievedB.aFactory.container.children.length).toBe(1);
expect(this.retrievedB.aFactory.container.children[0]).toBe(this.retrievedB.a2.$containerFactoryInstance.container);
});
});

describe("and when disposed both factory instances", function() {
Expand All @@ -86,6 +92,10 @@ describe("A factory", function() {
it("should not have disposed the instance", function() {
expect(this.disposalCount.b).toBeUndefined();
});

it("should release both containers", function() {
expect(this.retrievedB.aFactory.container.children.length).toBe(0);
});
});
});
})
10 changes: 8 additions & 2 deletions src/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
cacheItem.tag = this.tag;

this.refCounts[cacheItem.tag] = this.refCounts[cacheItem.tag] || {};
this.refCounts[cacheItem.tag][cacheItem.registration.key] = this.refCounts[cacheItem.tag][cacheItem.registration.key]++ || 1;
this.refCounts[cacheItem.tag][cacheItem.registration.key] = this.refCounts[cacheItem.tag][cacheItem.registration.key]+1 || 1;
},

release: function(cacheItem) {
Expand Down Expand Up @@ -94,7 +94,7 @@

set: function(cacheItem) {
this.cache.push(cacheItem);
this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]++ || 1;
this.refCounts[cacheItem.registration.key] = this.refCounts[cacheItem.registration.key]+1 || 1;
},

release: function(cacheItem) {
Expand All @@ -121,6 +121,7 @@
},

release: function(cacheItem) {
delete this.cache[cacheItem];
return true;
},

Expand Down Expand Up @@ -391,6 +392,11 @@
}
}
}

if (this.parent) {
var index = this.parent.children.indexOf(this);
this.parent.children.splice(index, 1);
}
return true;
},

Expand Down