Skip to content

Commit

Permalink
Merge branch 'release/0.4.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrockwell committed Sep 10, 2016
2 parents 25c51fc + 42555ac commit c5b7fe0
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 20 deletions.
16 changes: 9 additions & 7 deletions es5/lib/component/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,16 @@ var Link = function () {
});

methodNames.forEach(function (propertyName) {
var propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(_this2.parentLink), propertyName);
if (propertyDescriptor.value) {
propertyDescriptor.value = propertyDescriptor.value.bind(_this2.parentLink);
}
if (propertyDescriptor.get) {
propertyDescriptor.get = propertyDescriptor.get.bind(_this2.parentLink);
if (!instance[propertyName]) {
var propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(_this2.parentLink), propertyName);
if (propertyDescriptor.value) {
propertyDescriptor.value = propertyDescriptor.value.bind(_this2.parentLink);
}
if (propertyDescriptor.get) {
propertyDescriptor.get = propertyDescriptor.get.bind(_this2.parentLink);
}
Object.defineProperty(instance, propertyName, propertyDescriptor);
}
Object.defineProperty(instance, propertyName, propertyDescriptor);
});

this.parentLink.links.all.forEach(function (link) {
Expand Down
4 changes: 2 additions & 2 deletions es5/spec/component/component.link.apply.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Person = function (_Component) {
_createClass(Person, [{
key: "initialize",
value: function initialize() {
this.link("thought", Thought).apply(this);
this.link("thought", Thought).apply(this, 0);
}
}]);

Expand Down Expand Up @@ -71,6 +71,6 @@ describe("component.link.apply", function () {
});

it("should add the newly instantiated chain link to the designated collection", function () {
thought.options.should.eql([person, 1, 2, 3]);
thought.options.should.eql([person, 0, 1, 2, 3]);
});
});
12 changes: 11 additions & 1 deletion es5/spec/component/component.link.properties.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ var Person = function (_Component) {
this.link("arm", Arm);
this.link("pet", Pet);
}
}, {
key: "dna",
get: function get() {
return "abcdefg";
}
}]);

return Person;
Expand All @@ -49,7 +54,8 @@ var Arm = function (_Component2) {
_createClass(Arm, [{
key: "initialize",
value: function initialize(length) {
this.properties("length");
this.properties("length", "dna");
this.dna("dagca");
this.length(length);
}
}]);
Expand Down Expand Up @@ -90,6 +96,10 @@ describe("component.link.properties", function () {
person.arm().length(5).name().should.eql(name);
});

it("should be able to call overridden properties from a parent link", function () {
person.arm().dna("aabbagc").dna().should.eql("aabbagc");
});

it("should override identical parent properties", function () {
var petName = "Fluffy";
person.pet(petName).name().should.eql(petName);
Expand Down
7 changes: 6 additions & 1 deletion es5/spec/component/component.properties.then.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ describe(".properties.then(thenFunction)", function () {
});

it("should call .then each time the property has a value set", function () {
numbers.value("1").value("2").value("3");
numbers.value("1").value("2");

numbers.value();

numbers.value("3");

results.should.eql(["1", "2", "3"]);
});

Expand Down
10 changes: 6 additions & 4 deletions es6/lib/component/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ export default class Link {
});

methodNames.forEach(propertyName => {
const propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.parentLink), propertyName);
if (propertyDescriptor.value) { propertyDescriptor.value = propertyDescriptor.value.bind(this.parentLink); }
if (propertyDescriptor.get) { propertyDescriptor.get = propertyDescriptor.get.bind(this.parentLink); }
Object.defineProperty(instance, propertyName, propertyDescriptor);
if (!instance[propertyName]) {
const propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.parentLink), propertyName);
if (propertyDescriptor.value) { propertyDescriptor.value = propertyDescriptor.value.bind(this.parentLink); }
if (propertyDescriptor.get) { propertyDescriptor.get = propertyDescriptor.get.bind(this.parentLink); }
Object.defineProperty(instance, propertyName, propertyDescriptor);
}
});

this.parentLink.links.all.forEach(link => {
Expand Down
4 changes: 2 additions & 2 deletions es6/spec/component/component.link.apply.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Component from "../../lib/component/component.js";

class Person extends Component {
initialize() {
this.link("thought", Thought).apply(this);
this.link("thought", Thought).apply(this, 0);
}
}

Expand All @@ -27,6 +27,6 @@ describe("component.link.apply", () => {
});

it("should add the newly instantiated chain link to the designated collection", () => {
thought.options.should.eql([person, 1, 2, 3]);
thought.options.should.eql([person, 0, 1, 2, 3]);
});
});
13 changes: 12 additions & 1 deletion es6/spec/component/component.link.properties.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ class Person extends Component {
this.link("arm", Arm);
this.link("pet", Pet);
}

get dna() {
return "abcdefg";
}
}

class Arm extends Component {
initialize(length) {
this.properties("length");
this.properties("length", "dna");
this.dna("dagca");
this.length(length);
}
}
Expand Down Expand Up @@ -40,6 +45,12 @@ describe("component.link.properties", () => {
.name().should.eql(name);
});

it("should be able to call overridden properties from a parent link", () => {
person.arm()
.dna("aabbagc")
.dna().should.eql("aabbagc");
});

it("should override identical parent properties", () => {
const petName = "Fluffy";
person
Expand Down
7 changes: 6 additions & 1 deletion es6/spec/component/component.properties.then.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ describe(".properties.then(thenFunction)", () => {
it("should call .then each time the property has a value set", () => {
numbers
.value("1")
.value("2")
.value("2");

numbers.value();

numbers
.value("3");

results.should.eql([ "1", "2", "3" ]);
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mrt",
"version": "0.4.5",
"version": "0.4.6",
"description": "Helps build expressive chained interfaces.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c5b7fe0

Please sign in to comment.