Repository: incubator-weex
Updated Branches:
  refs/heads/0.16-dev 36352f2d9 -> 245ee614c


* [jsfm] update vanilla framework


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

Branch: refs/heads/0.16-dev
Commit: 6ecd723f053b1885a2afaaea3ad918fff71807ce
Parents: f40f596
Author: Hanks <zhanghan...@gmail.com>
Authored: Sun Jul 30 00:12:07 2017 +0800
Committer: Hanks <zhanghan...@gmail.com>
Committed: Sun Jul 30 00:12:07 2017 +0800

----------------------------------------------------------------------
 examples/vanilla/index.js         |  4 ++--
 html5/frameworks/vanilla/index.js | 21 ++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6ecd723f/examples/vanilla/index.js
----------------------------------------------------------------------
diff --git a/examples/vanilla/index.js b/examples/vanilla/index.js
index 4861a72..6ab399f 100644
--- a/examples/vanilla/index.js
+++ b/examples/vanilla/index.js
@@ -1,3 +1,5 @@
+// { "framework": "Vanilla" }
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -38,5 +40,3 @@ document.documentElement.appendChild(body)
 body.addEvent('click', function () {
   text.setAttr('value', 'Hello Weex')
 })
-
-sendTasks(id, [{ module: 'dom', method: 'createFinish', args: []}])

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6ecd723f/html5/frameworks/vanilla/index.js
----------------------------------------------------------------------
diff --git a/html5/frameworks/vanilla/index.js 
b/html5/frameworks/vanilla/index.js
index 45a2e69..5887f81 100644
--- a/html5/frameworks/vanilla/index.js
+++ b/html5/frameworks/vanilla/index.js
@@ -35,9 +35,10 @@ export function registerMethods (apis) {}
 
 export function prepareInstance (id, options, data) {}
 
-export function createInstance (id, code, options, data, serviceObjects) {
+export function createInstance (id, code, options = {}, data = {}, 
serviceObjects = {}) {
   const document = new config.Document(id, options.bundleUrl)
   const callbacks = {}
+  const instance = { id, data, document, callbacks }
 
   let lastCallbackId = 0
   document.addCallback = func => {
@@ -52,14 +53,14 @@ export function createInstance (id, code, options, data, 
serviceObjects) {
     }
     return callback(data)
   }
-  instanceMap[id] = document
+  instanceMap[id] = instance
 
   const globalObjects = Object.assign({
     Document: config.Document,
     Element: config.Element,
     Comment: config.Comment,
-    sendTasks: config.sendTasks,
-    id, options, data, document
+    sendTasks: (...args) => config.sendTasks(id, ...args),
+    options, document
   }, serviceObjects)
 
   const globalKeys = []
@@ -73,7 +74,9 @@ export function createInstance (id, code, options, data, 
serviceObjects) {
   const result = new Function(...globalKeys)
   result(...globalValues)
 
-  return { document }
+  config.sendTasks(id, [{ module: 'dom', method: 'createFinish', args: [] }], 
-1)
+
+  return instance
 }
 
 export function refreshInstance (id, data) {}
@@ -83,24 +86,24 @@ export function destroyInstance (id) {
 }
 
 export function getRoot (id) {
-  return instanceMap[id].body.toJSON()
+  return instanceMap[id].document.body.toJSON()
 }
 
 export function receiveTasks (id, tasks) {
   const jsHandlers = {
     fireEvent: (id, ref, type, data, domChanges) => {
-      const document = instanceMap[id]
+      const { document } = instanceMap[id]
       const el = document.getRef(ref)
       return document.fireEvent(el, type, data, domChanges)
     },
 
     callback: (id, funcId, data, ifLast) => {
-      const document = instanceMap[id]
+      const { document } = instanceMap[id]
       return document.handleCallback(funcId, data, ifLast)
     }
   }
 
-  const document = instanceMap[id]
+  const { document } = instanceMap[id] || {}
   if (document && Array.isArray(tasks)) {
     const results = []
     tasks.forEach((task) => {

Reply via email to