You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/03/31 07:28:37 UTC

[02/50] [abbrv] incubator-weex git commit: * [html5] fix error of getting multiple class names.

* [html5] fix error of getting multiple class names.


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

Branch: refs/heads/0.12-dev
Commit: 937c1caeb0847620fa99527d4e8236609b1cf4cd
Parents: 0edef41
Author: MrRaindrop <te...@gmail.com>
Authored: Sat Mar 18 23:32:12 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Sat Mar 18 23:32:12 2017 +0800

----------------------------------------------------------------------
 html5/render/vue/mixins/style.js | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/937c1cae/html5/render/vue/mixins/style.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/mixins/style.js b/html5/render/vue/mixins/style.js
index 325d685..bf00c0f 100644
--- a/html5/render/vue/mixins/style.js
+++ b/html5/render/vue/mixins/style.js
@@ -120,13 +120,15 @@ export default {
       const wh = {}
       const style = data.style
       const staticStyle = data.staticStyle
-      const classes = typeof data.class === 'string' ? [data.class] : (data.class || [])
-      const staticClass = typeof data.staticClass === 'string' ? [data.staticClass] : (data.staticClass || [])
+      const classes = (data.class || '').split(' ')
+      const staticClass = (data.staticClass || '').split(' ')
+      // const classes = typeof data.class === 'string' ? [data.class] : (data.class || [])
+      // const staticClass = typeof data.staticClass === 'string' ? [data.staticClass] : (data.staticClass || [])
       const clsNms = staticClass.concat(classes)
       function extendWHFrom (to, from) {
         if (!from) { return }
-        to.width = from.width
-        to.height = from.height
+        from.width && (to.width = from.width)
+        from.height && (to.height = from.height)
       }
       extendWHFrom(wh, this._getScopeStyle(clsNms))
       extendWHFrom(wh, staticStyle)
@@ -136,8 +138,10 @@ export default {
 
     // get style from class, staticClass, style and staticStyle.
     _getComponentStyle (data) {
-      const staticClassNames = (typeof data.staticClass === 'string') ? [data.staticClass] : (data.staticClass || [])
-      const classNames = (typeof data.class === 'string') ? [data.class] : (data.class || [])
+      const staticClassNames = (data.staticClass || '').split(' ')
+      const classNames = (data.class || '').split(' ')
+      // const staticClassNames = (typeof data.staticClass === 'string') ? [data.staticClass] : (data.staticClass || [])
+      // const classNames = (typeof data.class === 'string') ? [data.class] : (data.class || [])
       /**
        * merge styles. priority: high -> low
        *  1. data.style (bound style).