From 1a2f12099c91b81075826a8aa1820d964a3e4478 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Fri, 31 Jul 2015 15:09:15 +0300 Subject: bitbake: toastergui: libtoaster: Add guard against missing name property Add a debug warning if a JSON payload isn't compatible. i.e. without a name field. (Bitbake rev: e65de693670203ddcbf5f23ad2a91c523df879d8) Signed-off-by: Michael Wood Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/toaster') diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 115df80a96..22377f08f4 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js @@ -34,7 +34,14 @@ var libtoaster = (function (){ selectedCB(itemObj); return item; }, - matcher: function(item) { return ~item.name.toLowerCase().indexOf(this.query.toLowerCase()); }, + matcher: function(item) { + if (!item.hasOwnProperty('name')) { + console.log("Name property missing in data"); + return 0; + } + + return ~item.name.toLowerCase().indexOf(this.query.toLowerCase()); + }, highlighter: function (item) { if (item.hasOwnProperty('detail')) /* Use jquery to escape the value as text into a span */ -- cgit v1.2.3-54-g00ecf