* [jsfm] support to normalize buffer in deep object

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/fe8e8ed8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/fe8e8ed8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/fe8e8ed8

Branch: refs/heads/0.16-dev
Commit: fe8e8ed8d80c24753693f5635fdb94dc789a2a88
Parents: 5b7aae0
Author: Hanks <zhanghan...@gmail.com>
Authored: Thu Aug 3 17:04:28 2017 +0800
Committer: Hanks <zhanghan...@gmail.com>
Committed: Thu Aug 3 17:04:28 2017 +0800

----------------------------------------------------------------------
 html5/runtime/normalize.js | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/fe8e8ed8/html5/runtime/normalize.js
----------------------------------------------------------------------
diff --git a/html5/runtime/normalize.js b/html5/runtime/normalize.js
index f1e93b8..b5fab23 100644
--- a/html5/runtime/normalize.js
+++ b/html5/runtime/normalize.js
@@ -47,10 +47,19 @@ export function normalizePrimitive (v) {
     case 'Number':
     case 'String':
     case 'Boolean':
-    case 'Array':
-    case 'Object':
       return v
 
+    case 'Array':
+      return v.map(normalizePrimitive)
+
+    case 'Object': {
+      const obj = {}
+      for (const k in v) {
+        obj[k] = normalizePrimitive(v[k])
+      }
+      return obj
+    }
+
     case 'ArrayBuffer':
       return {
         '@type': 'binary',

Reply via email to