This is an automated email from the git hooks/post-receive script. New commit to branch support-webpack in repository oipf-stub. See https://gitlab.nuiton.org/codelutin/oipf-stub.git commit ff7a55b450b9065bc3f230a1e0a015fa83ca2813 Author: Samuel Maisonneuve <maisonneuve@codelutin.com> Date: Thu Feb 1 10:16:35 2018 +0100 Fix Collection and ScheduleRecording - Collection : fix constructor to take into account real Array signature and - ScheduleRecording : constructor (dont put a channel business object as internal representation of the channel business itself) and also fix toJSON to avoid mutation --- src/recording/ScheduledRecording.js | 8 ++++++-- src/shared/Collection.js | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/recording/ScheduledRecording.js b/src/recording/ScheduledRecording.js index 792562c..878a48c 100644 --- a/src/recording/ScheduledRecording.js +++ b/src/recording/ScheduledRecording.js @@ -34,7 +34,11 @@ module.exports = function(ctx) { ctx.__internal__.init(this); this.__internal__.setValues(values); - values.channel && this.__internal__.setField("channel", new Channel(0, values.channel)); + + // If values.channel is a raw object we convert it to the corresponding business object + if (values.channel && values.channel.__internal__ == null) { + this.__internal__.setField("channel", new Channel(0, values.channel)); + } // Recording has been newly scheduled. this.RECORDING_SCHEDULED = 0; @@ -341,7 +345,7 @@ module.exports = function(ctx) { // to json is used because getter are not enumerable in ES6 classes toJSON() { - let result = this.__internal__.getValues(); + let result = Object.assign({}, this.__internal__.getValues()); if (this.channel) { result.channel = this.channel.toJSON(); } diff --git a/src/shared/Collection.js b/src/shared/Collection.js index c04c3f2..91c227b 100644 --- a/src/shared/Collection.js +++ b/src/shared/Collection.js @@ -21,7 +21,13 @@ module.exports = function() { constructor(values) { super(); - values && this.push.apply(this, values); + + // An Array constructor can receive either a list of element or the size of the array. + // (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Obj...) + // Which means we need to filter out the case where the argument represents the length of the array... + if (!Number.isInteger(values)) { + this.push.apply(this, values); + } } item(index) { -- To stop receiving notification emails like this one, please contact SCM administrator <admin+scm@forge.codelutin.com>.