Skip to content

Commit c4252d3

Browse files
committed
fix weex merge flow types
1 parent ff55102 commit c4252d3

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

Diff for: src/entries/weex-compiler.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export function compile (
1111
options = options || {}
1212
const errors = []
1313
// allow injecting modules/directives
14+
const baseModules = baseOptions.modules || []
1415
const modules = options.modules
15-
? baseOptions.modules.concat(options.modules)
16-
: baseOptions.modules
16+
? baseModules.concat(options.modules)
17+
: baseModules
1718
const directives = options.directives
1819
? extend(extend({}, baseOptions.directives), options.directives)
1920
: baseOptions.directives

Diff for: src/platforms/weex/compiler/modules/style.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
1919
const warn = options.warn || baseWarn
2020
const staticStyle = getAndRemoveAttr(el, 'style')
2121
const { dynamic, styleResult } = parseStaticStyle(staticStyle, options)
22-
if (dynamic) {
23-
if (process.env.NODE_ENV !== 'production') {
24-
warn(
25-
`style="${staticStyle}": ` +
26-
'Interpolation inside attributes has been deprecated. ' +
27-
'Use v-bind or the colon shorthand instead.'
28-
)
29-
}
22+
if (process.env.NODE_ENV !== 'production' && dynamic) {
23+
warn(
24+
`style="${String(staticStyle)}": ` +
25+
'Interpolation inside attributes has been deprecated. ' +
26+
'Use v-bind or the colon shorthand instead.'
27+
)
3028
}
3129
if (!dynamic && styleResult) {
3230
el.staticStyle = styleResult
@@ -50,7 +48,7 @@ function genData (el: ASTElement): string {
5048
return data
5149
}
5250

53-
function parseStaticStyle (staticStyle?: string, options: CompilerOptions): StaticStyleResult {
51+
function parseStaticStyle (staticStyle: ?string, options: CompilerOptions): StaticStyleResult {
5452
// "width: 200px; height: 200px;" -> {width: 200, height: 200}
5553
// "width: 200px; height: {{y}}" -> {width: 200, height: y}
5654
let dynamic = false

Diff for: src/platforms/weex/runtime/modules/class.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
1414
}
1515

1616
const oldClassList = []
17-
if (oldData.staticClass) {
18-
oldClassList.push.apply(oldClassList, oldData.staticClass)
17+
// unlike web, weex vnode staticClass is an Array
18+
const oldStaticClass: any = oldData.staticClass
19+
if (oldStaticClass) {
20+
oldClassList.push.apply(oldClassList, oldStaticClass)
1921
}
2022
if (oldData.class) {
2123
oldClassList.push.apply(oldClassList, oldData.class)
2224
}
2325

2426
const classList = []
25-
if (data.staticClass) {
26-
classList.push.apply(classList, data.staticClass)
27+
// unlike web, weex vnode staticClass is an Array
28+
const staticClass: any = data.staticClass
29+
if (staticClass) {
30+
classList.push.apply(classList, staticClass)
2731
}
2832
if (data.class) {
2933
classList.push.apply(classList, data.class)
@@ -36,7 +40,9 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
3640
}
3741

3842
function getStyle (oldClassList: Array<string>, classList: Array<string>, ctx: Component): Object {
39-
const stylesheet = ctx.$options.style || {}
43+
// style is a weex-only injected object
44+
// compiled from <style> tags in weex files
45+
const stylesheet: any = ctx.$options.style || {}
4046
const result = {}
4147
classList.forEach(name => {
4248
const style = stylesheet[name]

Diff for: src/platforms/weex/runtime/modules/style.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
2525
}
2626
let cur, name
2727
const elm = vnode.elm
28-
const oldStyle = oldVnode.data.style || {}
29-
let style = vnode.data.style || {}
28+
const oldStyle: any = oldVnode.data.style || {}
29+
let style: any = vnode.data.style || {}
3030

3131
const needClone = style.__ob__
3232

0 commit comments

Comments
 (0)