diff --git a/packages/ember-metal/lib/computed_macros.js b/packages/ember-metal/lib/computed_macros.js index 8075de399cb..ab5a5c94bb4 100644 --- a/packages/ember-metal/lib/computed_macros.js +++ b/packages/ember-metal/lib/computed_macros.js @@ -467,12 +467,14 @@ export var and = generateComputedWithProperties(function(properties) { @public */ export var or = generateComputedWithProperties(function(properties) { + var value; for (var key in properties) { - if (properties.hasOwnProperty(key) && properties[key]) { - return properties[key]; + value = properties[key]; + if (properties.hasOwnProperty(key) && value) { + return value; } } - return false; + return value; }); /** diff --git a/packages/ember-runtime/tests/computed/computed_macros_test.js b/packages/ember-runtime/tests/computed/computed_macros_test.js index 97b5279fcf7..e187ff64e9b 100644 --- a/packages/ember-runtime/tests/computed/computed_macros_test.js +++ b/packages/ember-runtime/tests/computed/computed_macros_test.js @@ -277,6 +277,10 @@ testBoth('computed.or', function(get, set) { equal(get(obj, 'oneOrTwo'), false, 'nore one nore two'); + set(obj, 'two', null); + + equal(get(obj, 'oneOrTwo'), null, 'returns last falsy value as in ||'); + set(obj, 'two', true); equal(get(obj, 'oneOrTwo'), true, 'one or two');