Browse Source

Fix config logic

pull/104/head
Masayuki Tanaka 11 years ago
parent
commit
5e0a4af4af
  1. 11
      c3.js
  2. 4
      c3.min.js

11
c3.js

@ -78,12 +78,17 @@
}
function getConfig(keys, defaultValue) {
var i, target = config, isDefaultObject = typeof defaultValue === 'object';
var target = config, i, isLast, nextTarget;
for (i = 0; i < keys.length; i++) {
if (!(keys[i] in target) || (i === keys.length - 1 && !isDefaultObject && typeof target[keys[i]] === 'object')) {
// return default if key not found
if (typeof target === 'object' && !(keys[i] in target)) { return defaultValue; }
// Check next key's value
isLast = (i === keys.length - 1);
nextTarget = target[keys[i]];
if ((!isLast && typeof nextTarget !== 'object') || (isLast && typeof defaultValue !== 'object' && typeof nextTarget === 'object')) {
return defaultValue;
}
target = target[keys[i]];
target = nextTarget;
}
return target;
}

4
c3.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save