[bitbake-devel] [PATCH 14/22] bitbake: toastergui: libtoaster: Add guard against missing name property

Ed Bartosh ed.bartosh at linux.intel.com
Fri Jul 31 12:09:15 UTC 2015


From: Michael Wood <michael.g.wood at intel.com>

Add a debug warning if a JSON payload isn't compatible. i.e. without a
name field.

Signed-off-by: Michael Wood <michael.g.wood at intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
 lib/toaster/toastergui/static/js/libtoaster.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/toaster/toastergui/static/js/libtoaster.js b/lib/toaster/toastergui/static/js/libtoaster.js
index 115df80..22377f0 100644
--- a/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/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 */
-- 
2.1.4




More information about the bitbake-devel mailing list