From 7bfa20933b7068500361f5d3a290426ace28bf78 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Thu, 19 Nov 2015 12:00:16 +0100 Subject: [PATCH] Phi: allow setting of properties via hash Defining the set of properties for the knockoutjs bridge via array of array is clumsy, allow setting those via an object aka hash is much easier. --- Phi/lib/knockprops.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Phi/lib/knockprops.js b/Phi/lib/knockprops.js index 564ba18d2..8ff0e8d34 100644 --- a/Phi/lib/knockprops.js +++ b/Phi/lib/knockprops.js @@ -162,9 +162,17 @@ define(['knockout'], function(ko) { self.aliases = {}; self.setAliases = function(arg) { - arg.forEach(function(a) { - self.aliases[a[0]] = a[1]; - }); + if( Object.prototype.toString.call( arg ) === '[object Array]' ) { + // [ + // [ shortcut, propertypath ], + // [ othercut, otherproperty ], + // ] + arg.forEach(function(a) { + self.aliases[a[0]] = a[1]; + }); + } else { + self.aliases = arg; + } } self.props = {};