From e30f8628db7f3f994407c219130255af44343142 Mon Sep 17 00:00:00 2001 From: HirokiUchikawa Date: Wed, 9 May 2018 19:19:37 +0900 Subject: [PATCH] Revert runtime/util --- red/runtime/util.js | 2 +- test/red/runtime/util_spec.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/red/runtime/util.js b/red/runtime/util.js index 4d077c21f..257e87777 100644 --- a/red/runtime/util.js +++ b/red/runtime/util.js @@ -240,7 +240,7 @@ function getMessageProperty(msg,expr) { var msgPropParts = normalisePropertyExpression(expr); var m; msgPropParts.reduce(function(obj, key) { - result = ((typeof obj !== "undefined") && (typeof obj[key] !== "undefined") ? obj[key] : undefined); + result = (typeof obj[key] !== "undefined" ? obj[key] : undefined); return result; }, msg); return result; diff --git a/test/red/runtime/util_spec.js b/test/red/runtime/util_spec.js index c3e797d26..1b7438efd 100644 --- a/test/red/runtime/util_spec.js +++ b/test/red/runtime/util_spec.js @@ -153,9 +153,11 @@ describe("red/util", function() { var v = util.getMessageProperty({a:"foo"},"msg.b"); should.not.exist(v); }); - it('should return undefined if property parent does not exist', function() { - var v = util.getMessageProperty({a:"foo"},"msg.a.b.c"); - should.not.exist(v); + it('should throw error if property parent does not exist', function() { + /*jshint immed: false */ + (function() { + util.getMessageProperty({a:"foo"},"msg.a.b.c"); + }).should.throw(); }); it('retrieves a property with array syntax', function() { var v = util.getMessageProperty({a:["foo","bar"]},"msg.a[0]");