ソースを参照

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.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Michael Wood 8 年 前
コミット
e65de69367
1 ファイル変更8 行追加1 行削除
  1. 8 1
      lib/toaster/toastergui/static/js/libtoaster.js

+ 8 - 1
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 */