Skip to content

Commit 1dd6b6f

Browse files
committed
refactor: adjust weex branch coverage and build for merging into dev
1 parent 661bfe5 commit 1dd6b6f

File tree

10 files changed

+69
-55
lines changed

10 files changed

+69
-55
lines changed

Diff for: src/compiler/codegen/events.js

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function genHandlers (
4747
}
4848
4949
// Generate handler code with binding params on Weex
50+
/* istanbul ignore next */
5051
function genWeexHandler (params: Array<any>, handlerCode: string) {
5152
let innerHandlerCode = handlerCode
5253
const exps = params.filter(exp => simplePathRE.test(exp) && exp !== '$event')
@@ -82,6 +83,7 @@ function genHandler (
8283
if (isMethodPath || isFunctionExpression) {
8384
return handler.value
8485
}
86+
/* istanbul ignore if */
8587
if (__WEEX__ && handler.params) {
8688
return genWeexHandler(handler.params, handler.value)
8789
}
@@ -121,6 +123,7 @@ function genHandler (
121123
: isFunctionExpression
122124
? `(${handler.value})($event)`
123125
: handler.value
126+
/* istanbul ignore if */
124127
if (__WEEX__ && handler.params) {
125128
return genWeexHandler(handler.params, code + handlerCode)
126129
}

Diff for: src/compiler/codegen/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,17 @@ function genProps (props: Array<{ name: string, value: any }>): string {
487487
let res = ''
488488
for (let i = 0; i < props.length; i++) {
489489
const prop = props[i]
490-
res += `"${prop.name}":${generateValue(prop.value)},`
490+
/* istanbul ignore if */
491+
if (__WEEX__) {
492+
res += `"${prop.name}":${generateValue(prop.value)},`
493+
} else {
494+
res += `"${prop.name}":${transformSpecialNewlines(prop.value)},`
495+
}
491496
}
492497
return res.slice(0, -1)
493498
}
494499

500+
/* istanbul ignore next */
495501
function generateValue (value) {
496502
if (typeof value === 'string') {
497503
return transformSpecialNewlines(value)

Diff for: src/core/vdom/create-component.js

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export function createComponent (
200200
// Weex specific: invoke recycle-list optimized @render function for
201201
// extracting cell-slot template.
202202
// https://github.com/Hanks10100/weex-native-directive/tree/master/component
203+
/* istanbul ignore if */
203204
if (__WEEX__ && isRecyclableComponent(vnode)) {
204205
return renderRecyclableComponentTemplate(vnode)
205206
}

Diff for: src/core/vdom/helpers/update-listeners.js

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function updateListeners (
5454
def = cur = on[name]
5555
old = oldOn[name]
5656
event = normalizeEvent(name)
57+
/* istanbul ignore if */
5758
if (__WEEX__ && isPlainObject(def)) {
5859
cur = def.handler
5960
event.params = def.params

Diff for: src/platforms/web/compiler/modules/model.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
import {
14+
addRawAttr,
1415
getBindingAttr,
1516
getAndRemoveAttr
1617
} from 'compiler/helpers'
@@ -77,11 +78,6 @@ function cloneASTElement (el) {
7778
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
7879
}
7980

80-
function addRawAttr (el, name, value) {
81-
el.attrsMap[name] = value
82-
el.attrsList.push({ name, value })
83-
}
84-
8581
export default {
8682
preTransformNode
8783
}

Diff for: src/platforms/weex/compiler/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isReservedTag,
1313
canBeLeftOpenTag,
1414
getTagNamespace
15-
} from '../util/index'
15+
} from '../util/element'
1616

1717
export const baseOptions: WeexCompilerOptions = {
1818
modules,

Diff for: src/platforms/weex/runtime/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isReservedTag,
1313
isRuntimeComponent,
1414
isUnknownElement
15-
} from 'weex/util/index'
15+
} from 'weex/util/element'
1616

1717
// install platform specific utils
1818
Vue.config.mustUseProp = mustUseProp

Diff for: src/platforms/weex/util/element.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* @flow */
2+
3+
// These util functions are split into its own file because Rollup cannot drop
4+
// makeMap() due to potential side effects, so these variables end up
5+
// bloating the web builds.
6+
7+
import { makeMap } from 'shared/util'
8+
9+
export const isReservedTag = makeMap(
10+
'template,script,style,element,content,slot,link,meta,svg,view,' +
11+
'a,div,img,image,text,span,input,switch,textarea,spinner,select,' +
12+
'slider,slider-neighbor,indicator,canvas,' +
13+
'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
14+
'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
15+
true
16+
)
17+
18+
// Elements that you can, intentionally, leave open (and which close themselves)
19+
// more flexible than web
20+
export const canBeLeftOpenTag = makeMap(
21+
'web,spinner,switch,video,textarea,canvas,' +
22+
'indicator,marquee,countdown',
23+
true
24+
)
25+
26+
export const isRuntimeComponent = makeMap(
27+
'richtext,transition,transition-group',
28+
true
29+
)
30+
31+
export const isUnaryTag = makeMap(
32+
'embed,img,image,input,link,meta',
33+
true
34+
)
35+
36+
export function mustUseProp (tag: string, type: ?string, name: string): boolean {
37+
return false
38+
}
39+
40+
export function getTagNamespace (tag?: string): string | void { }
41+
42+
export function isUnknownElement (tag?: string): boolean {
43+
return false
44+
}
45+
46+
export function query (el: string | Element, document: Object) {
47+
// document is injected by weex factory wrapper
48+
const placeholder = document.createComment('root')
49+
placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
50+
document.documentElement.appendChild(placeholder)
51+
return placeholder
52+
}

Diff for: src/platforms/weex/util/index.js

-46
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,10 @@
11
/* @flow */
22
declare var document: Object;
33

4-
import { makeMap } from 'shared/util'
54
import { warn } from 'core/util/index'
65

76
export const RECYCLE_LIST_MARKER = '@inRecycleList'
87

9-
export const isReservedTag = makeMap(
10-
'template,script,style,element,content,slot,link,meta,svg,view,' +
11-
'a,div,img,image,text,span,input,switch,textarea,spinner,select,' +
12-
'slider,slider-neighbor,indicator,canvas,' +
13-
'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
14-
'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
15-
true
16-
)
17-
18-
// Elements that you can, intentionally, leave open (and which close themselves)
19-
// more flexible than web
20-
export const canBeLeftOpenTag = makeMap(
21-
'web,spinner,switch,video,textarea,canvas,' +
22-
'indicator,marquee,countdown',
23-
true
24-
)
25-
26-
export const isRuntimeComponent = makeMap(
27-
'richtext,transition,transition-group',
28-
true
29-
)
30-
31-
export const isUnaryTag = makeMap(
32-
'embed,img,image,input,link,meta',
33-
true
34-
)
35-
36-
export function mustUseProp (tag: string, type: ?string, name: string): boolean {
37-
return false
38-
}
39-
40-
export function getTagNamespace (tag?: string): string | void { }
41-
42-
export function isUnknownElement (tag?: string): boolean {
43-
return false
44-
}
45-
46-
export function query (el: string | Element, document: Object) {
47-
// document is injected by weex factory wrapper
48-
const placeholder = document.createComment('root')
49-
placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
50-
document.documentElement.appendChild(placeholder)
51-
return placeholder
52-
}
53-
548
// Register the component hook to weex native render engine.
559
// The hook will be triggered by native, not javascript.
5610
export function registerComponentHook (

Diff for: test/unit/karma.cover.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module.exports = function (config) {
2424
'test/',
2525
'src/compiler/parser/html-parser.js',
2626
'src/core/instance/proxy.js',
27-
'src/sfc/deindent.js'
27+
'src/sfc/deindent.js',
28+
'src/platforms/weex/'
2829
]
2930
}]]
3031
}

0 commit comments

Comments
 (0)