Skip to content

Commit d31ab8e

Browse files
author
RubyLouvre
committed
添加覆盖率测试
1 parent 38d8b4e commit d31ab8e

14 files changed

+204
-155
lines changed

.coveralls.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
service_name: travis-ci
2+
repo_token: 7PbHs1UhR24n9sP01rhKsHLXHaU4rUCvU

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ script:
1616
branches:
1717
only:
1818
- master
19+
after_script:
20+
- npm run coveralls

build.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
var a = require('./buildIE6')
2-
var b = require('./buildIE6Test')
3-
var c = require('./buildIE9')
4-
var d = require('./buildIE9Test')
5-
Promise.all([a,b, c,d]).then(function() {
1+
var array = [
2+
require('./buildIE6'),
3+
require('./buildIE6Test'),
4+
//require('./buildIE9'),
5+
// require('./buildIE9Test')
6+
]
7+
Promise.all(array).then(function() {
68
console.log('build complete!!!')
79
}).catch(function() {
810
console.log('build error!!!')

buildIE6Test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ module.exports = rollup.rollup({
1818
cache: cache,
1919

2020
plugins: [
21-
// istanbul({
22-
// exclude: ['test/**/*.js']
23-
// })
21+
istanbul({
22+
exclude: ['test/**/*.js']
23+
})
2424
]
2525
}).then(function(bundle) {
2626
// Generate bundle + sourcemap

dist/avalon.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
built in 2016-11-30:21:49 version 2.2.2 by 司徒正美
2+
built in 2016-12-1:11:37 version 2.2.2 by 司徒正美
33
https://github.com/RubyLouvre/avalon/tree/2.2.1
44
添加计算属性
55
添加事务
@@ -1694,17 +1694,18 @@ fix 空字符串不生成节点的BUG
16941694
continue;
16951695
}
16961696
//IE6中classNamme, htmlFor等无法检测它们为内建属性 
1697-
if (msie < 8 && /[A-Z]/.test(propName)) {
1697+
if (avalon.msie < 8 && /[A-Z]/.test(propName)) {
16981698
node[propName] = val + '';
16991699
continue;
17001700
}
17011701
//SVG只能使用setAttribute(xxx, yyy), VML只能使用node.xxx = yyy ,
17021702
//HTML的固有属性必须node.xxx = yyy
1703-
var isInnate = !avalon.modern && isVML(node) ? true : isInnateProps(node.nodeName, attrName);
17041703
/* istanbul ignore next */
1704+
var isInnate = !avalon.modern && isVML(node) ? true : isInnateProps(node.nodeName, attrName);
17051705
if (isInnate) {
17061706
if (attrName === 'href' || attrName === 'src') {
1707-
if (msie < 8) {
1707+
/* istanbul ignore if */
1708+
if (avalon.msie < 8) {
17081709
val = String(val).replace(ramp, '&'); //处理IE67自动转义的问题
17091710
}
17101711
}
@@ -1718,11 +1719,13 @@ fix 空字符串不生成节点的BUG
17181719
// 未知名称。\/n
17191720
// e.message大概这样,需要trim
17201721
//IE6-8,元素节点不支持其他元素节点的内置属性,如src, href, for
1722+
/* istanbul ignore next */
17211723
avalon.log(String(e.message).trim(), attrName, val);
17221724
}
17231725
}
17241726
}
17251727
var innateMap = {};
1728+
17261729
function isInnateProps(nodeName, attrName) {
17271730
var key = nodeName + ":" + attrName;
17281731
if (key in innateMap) {
@@ -3280,11 +3283,13 @@ fix 空字符串不生成节点的BUG
32803283
try {
32813284
dom.innerHTML = template;
32823285
} catch (e) {
3286+
/* istanbul ignore next*/
32833287
this.hackIE(dom, this.nodeName, template, props);
32843288
}
32853289
break;
32863290
case 'option':
32873291
//IE6-8,为option添加文本子节点,不会同步到text属性中
3292+
/* istanbul ignore next */
32883293
if (msie < 9) dom.text = template;
32893294
default:
32903295
/* istanbul ignore next */
@@ -3297,6 +3302,8 @@ fix 空字符串不生成节点的BUG
32973302
}
32983303
return this.dom = dom;
32993304
},
3305+
3306+
/* istanbul ignore next */
33003307
hackIE: function hackIE(dom, nodeName, template) {
33013308
switch (nodeName) {
33023309
case 'style':
@@ -3387,7 +3394,7 @@ fix 空字符串不生成节点的BUG
33873394

33883395
function VFragment(children, key, val, index) {
33893396
this.nodeName = '#document-fragment';
3390-
this.children = children || [];
3397+
this.children = children;
33913398
this.key = key;
33923399
this.val = val;
33933400
this.index = index;
@@ -3417,7 +3424,7 @@ fix 空字符串不生成节点的BUG
34173424
return f;
34183425
},
34193426
toHTML: function toHTML() {
3420-
var c = this.children || [];
3427+
var c = this.children;
34213428
return c.map(function (el) {
34223429
return avalon.vdom(el, 'toHTML');
34233430
}).join('');

dist/avalon.modern.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
built in 2016-11-30:21:49 version 2.2.2 by 司徒正美
2+
built in 2016-12-1:0:56 version 2.2.2 by 司徒正美
33
https://github.com/RubyLouvre/avalon/tree/2.2.1
44
添加计算属性
55
添加事务
@@ -2669,7 +2669,7 @@ https://github.com/RubyLouvre/avalon/tree/2.2.1
26692669

26702670
function VFragment(children, key, val, index) {
26712671
this.nodeName = '#document-fragment'
2672-
this.children = children || []
2672+
this.children = children
26732673
this.key = key
26742674
this.val = val
26752675
this.index = index
@@ -2699,7 +2699,7 @@ https://github.com/RubyLouvre/avalon/tree/2.2.1
26992699
return f
27002700
},
27012701
toHTML: function toHTML() {
2702-
var c = this.children || []
2702+
var c = this.children
27032703
return c.map(function (el) {
27042704
return avalon$2.vdom(el, 'toHTML')
27052705
}).join('')

karma.conf.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,10 @@ module.exports = function(config) {
9292
}
9393
},
9494
coverageReporter: {
95-
dir: 'coverage/',
96-
reporters: [{
97-
type: 'text'
98-
}, {
99-
type: 'html',
100-
subdir: 'html'
101-
}]
95+
reporters: [
96+
{type: 'text-summary', subdir: '.'},
97+
{type: 'lcov', subdir: '.', dir: 'coverage/'}
98+
]
10299

103100
},
104101
// Continuous Integration mode

package.json

+44-42
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
11
{
2-
"name": "avalon2",
3-
"license": "MIT",
4-
"repository": {
5-
"type": "git",
6-
"url": "https://github.com/RubyLouvre/avalon.git"
7-
},
8-
"version": "2.2.2",
9-
"description": "an elegant efficient express mvvm framework",
10-
"main": "dist/avalon.js",
11-
"keywords": [
12-
"javascript",
13-
"mvvm",
14-
"virtual dom"
15-
],
16-
"scripts": {
17-
"buildAvalon": "node build",
18-
"build": "karma start karma.conf"
19-
},
20-
"dependencies": {},
21-
"devDependencies": {
22-
"babel-core": "^6.17.0",
23-
"babel-preset-avalon": "^1.0.0",
24-
"es3ify": "^0.2.2",
25-
"karma": "^0.12.0",
26-
"karma-chrome-launcher": "^0.1.2",
27-
"karma-coverage": "^1.1.1",
28-
"karma-firefox-launcher": "^1.0.0",
29-
"karma-ie-launcher": "^1.0.0",
30-
"karma-jasmine": "^0.2.2",
31-
"karma-phantomjs-launcher": "^1.0.2",
32-
"karma-sauce-launcher": "^0.2.14",
33-
"karma-sourcemap-loader": "^0.3.7",
34-
"karma-spec-reporter": "0.0.26",
35-
"rollup": "^0.36.3",
36-
"rollup-plugin-istanbul": "^1.1.0",
37-
"rollup-plugin-sourcemaps": "^0.4.1",
38-
"semicolon-less": "^0.7.0"
39-
},
40-
"bugs": {
41-
"url": "https://github.com/RubyLouvre/avalon/issues"
42-
}
43-
}
2+
"name": "avalon2",
3+
"license": "MIT",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/RubyLouvre/avalon.git"
7+
},
8+
"version": "2.2.2",
9+
"description": "an elegant efficient express mvvm framework",
10+
"main": "dist/avalon.js",
11+
"keywords": [
12+
"javascript",
13+
"mvvm",
14+
"virtual dom"
15+
],
16+
"scripts": {
17+
"buildAvalon": "node build",
18+
"build": "karma start karma.conf",
19+
"coveralls": "cat ./coverage/lcov/lcov.info | ./node_modules/.bin/coveralls"
20+
},
21+
"dependencies": {},
22+
"devDependencies": {
23+
"babel-core": "^6.17.0",
24+
"babel-preset-avalon": "^1.0.0",
25+
"coveralls": "^2.11.15",
26+
"es3ify": "^0.2.2",
27+
"karma": "^0.12.0",
28+
"karma-chrome-launcher": "^0.1.2",
29+
"karma-coverage": "^1.1.1",
30+
"karma-firefox-launcher": "^1.0.0",
31+
"karma-ie-launcher": "^1.0.0",
32+
"karma-jasmine": "^0.2.2",
33+
"karma-phantomjs-launcher": "^1.0.2",
34+
"karma-sauce-launcher": "^0.2.14",
35+
"karma-sourcemap-loader": "^0.3.7",
36+
"karma-spec-reporter": "0.0.26",
37+
"rollup": "^0.36.3",
38+
"rollup-plugin-istanbul": "^1.1.0",
39+
"rollup-plugin-sourcemaps": "^0.4.1",
40+
"semicolon-less": "^0.7.0"
41+
},
42+
"bugs": {
43+
"url": "https://github.com/RubyLouvre/avalon/issues"
44+
}
45+
}

perf/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}, 0) / array.length, 'ms')
4848
clearInterval(id)
4949
}
50-
}, 50)
50+
}, 500)
5151

5252
</script>
5353
</head>
@@ -59,7 +59,8 @@
5959
<table border="1">
6060
<tr><th ms-for='el in @header'>{{el}}</th></tr>
6161
<tr ms-for='tr in @list'>
62-
<td ms-for='td in tr | selectBy(["name","age","sex"])' ms-attr="{align:td === 'age' ?'left':'right'}">{{td}}</td>
62+
<td ms-for="td in tr | selectBy(['name','age','sex'])"
63+
ms-attr="{align:td === 'age' ?'left':'right'}">{{td}}</td>
6364
</tr>
6465
</table>
6566
</div>

src/dom/attr/compact.js

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
import { avalon, window, document, msie } from '../../seed/core'
1+
import { avalon, window, document } from '../../seed/core'
32
import { propMap } from './propMap'
43
import { isVML } from './isVML'
54
import { compactParseJSON } from './parseJSON.compact'
@@ -8,41 +7,42 @@ var rsvg = /^\[object SVG\w*Element\]$/
87
var ramp = /&amp;/g
98
export function updateAttrs(node, attrs) {
109
for (var attrName in attrs) {
11-
try {
12-
var val = attrs[attrName]
13-
// 处理路径属性
14-
/* istanbul ignore if*/
15-
10+
try {
11+
var val = attrs[attrName]
12+
// 处理路径属性
13+
/* istanbul ignore if*/
14+
1615
//处理HTML5 data-*属性 SVG
1716
if (attrName.indexOf('data-') === 0 || rsvg.test(node)) {
1817
node.setAttribute(attrName, val)
1918
} else {
2019
var propName = propMap[attrName] || attrName
21-
/* istanbul ignore if */
20+
/* istanbul ignore if */
2221
if (typeof node[propName] === 'boolean') {
2322
node[propName] = !!val
24-
//布尔属性必须使用el.xxx = true|false方式设值
25-
//如果为false, IE全系列下相当于setAttribute(xxx,''),
26-
//会影响到样式,需要进一步处理
23+
//布尔属性必须使用el.xxx = true|false方式设值
24+
//如果为false, IE全系列下相当于setAttribute(xxx,''),
25+
//会影响到样式,需要进一步处理
2726
}
2827

29-
if (val === false) {//移除属性
28+
if (val === false) { //移除属性
3029
node.removeAttribute(propName)
3130
continue
3231
}
3332
//IE6中classNamme, htmlFor等无法检测它们为内建属性 
34-
if(msie < 8 && /[A-Z]/.test(propName)){
35-
node[propName] = val + ''
36-
continue
33+
if (avalon.msie < 8 && /[A-Z]/.test(propName)) {
34+
node[propName] = val + ''
35+
continue
3736
}
3837
//SVG只能使用setAttribute(xxx, yyy), VML只能使用node.xxx = yyy ,
3938
//HTML的固有属性必须node.xxx = yyy
40-
var isInnate = (!avalon.modern && isVML(node)) ? true :
41-
isInnateProps(node.nodeName, attrName)
4239
/* istanbul ignore next */
40+
var isInnate = (!avalon.modern && isVML(node)) ? true :
41+
isInnateProps(node.nodeName, attrName)
4342
if (isInnate) {
4443
if (attrName === 'href' || attrName === 'src') {
45-
if (msie < 8) {
44+
/* istanbul ignore if */
45+
if (avalon.msie < 8) {
4646
val = String(val).replace(ramp, '&') //处理IE67自动转义的问题
4747
}
4848
}
@@ -56,11 +56,13 @@ export function updateAttrs(node, attrs) {
5656
// 未知名称。\/n
5757
// e.message大概这样,需要trim
5858
//IE6-8,元素节点不支持其他元素节点的内置属性,如src, href, for
59+
/* istanbul ignore next */
5960
avalon.log(String(e.message).trim(), attrName, val)
6061
}
6162
}
6263
}
6364
var innateMap = {}
65+
6466
function isInnateProps(nodeName, attrName) {
6567
var key = nodeName + ":" + attrName
6668
if (key in innateMap) {
@@ -75,12 +77,11 @@ try {
7577
avalon.parseJSON = compactParseJSON
7678
}
7779

78-
avalon.fn.attr = function (name, value) {
80+
avalon.fn.attr = function(name, value) {
7981
if (arguments.length === 2) {
8082
this[0].setAttribute(name, value)
8183
return this
8284
} else {
8385
return this[0].getAttribute(name)
8486
}
85-
}
86-
87+
}

0 commit comments

Comments
 (0)