avalon2
Version:
an elegant efficient express mvvm framework
295 lines (294 loc) • 10.8 kB
HTML
<html lang="en">
<head>
<title>Code coverage report for dom/event/compact.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="../../prettify.css" />
<link rel="stylesheet" href="../../base.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(../../sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1>
<a href="../../index.html">all files</a> / <a href="index.html">dom/event/</a> compact.js
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>40/40</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>30/30</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>8/8</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>40/40</span>
</div>
<div class='fl pad1y'>
<span class="strong">17 statements, 5 functions, 14 branches</span>
<span class="quiet">Ignored</span>
</div>
</div>
</div>
<div class='status-line high'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">21×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">3×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">62×</span>
<span class="cline-any cline-yes">62×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">62×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-yes">2×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-yes">1×</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { avalon, eventHooks, modern, document, root } from '../../seed/core'
import { canBubbleUp } from './canBubbleUp'
import { avEvent } from './share'
export {
avEvent
}
/* istanbul ignore if */
<span class="skip-if-branch" title="if path not taken" >I</span>if (!modern) {
<span class="cstat-skip" title="statement not covered" > delete canBubbleUp.change</span>
<span class="cstat-skip" title="statement not covered" > delete canBubbleUp.select</span>
}
/* istanbul ignore next */
avalon._nativeBind = modern ? function (el, type, fn, capture) {
el.addEventListener(type, fn, !!capture)
} : <span class="fstat-skip" title="function not covered" ><span class="branch-1 cbranch-skip" title="branch not covered" >function (el, type, fn) {</span></span>
<span class="cstat-skip" title="statement not covered" > el.attachEvent('on' + type, fn)</span>
}
/* istanbul ignore next */
avalon._nativeUnBind = modern ? <span class="fstat-skip" title="function not covered" >function (el, type, fn, a) {</span>
<span class="cstat-skip" title="statement not covered" > el.removeEventListener(type, fn, !!a)</span>
} : <span class="fstat-skip" title="function not covered" ><span class="branch-1 cbranch-skip" title="branch not covered" >function (el, type, fn) {</span></span>
<span class="cstat-skip" title="statement not covered" > el.detachEvent('on' + type, fn)</span>
}
/* istanbul ignore next */
avalon.fireDom = function (elem, type, opts) {
<span class="skip-if-branch" title="else path not taken" >E</span>if (document.createEvent) {
var hackEvent = document.createEvent('Events')
hackEvent.initEvent(type, true, true, opts)
avalon.shadowCopy(hackEvent, opts)
elem.dispatchEvent(hackEvent)
} else <span class="cstat-skip" title="statement not covered" >if (root.contains(elem)) {//IE6-8触发事件必须保证在DOM树中,否则报'SCRIPT16389: 未指明的错误'</span>
<span class="cstat-skip" title="statement not covered" > hackEvent = document.createEventObject()</span>
<span class="cstat-skip" title="statement not covered" > if (opts)</span>
<span class="cstat-skip" title="statement not covered" > avalon.shadowCopy(hackEvent, opts)</span>
<span class="cstat-skip" title="statement not covered" > try {</span>
<span class="cstat-skip" title="statement not covered" > elem.fireEvent('on' + type, hackEvent)</span>
} catch (e) {
<span class="cstat-skip" title="statement not covered" > avalon.log('fireDom', type, 'args error')</span>
}
}
}
var rmouseEvent = /^(?:mouse|contextmenu|drag)|click/
/* istanbul ignore next */
avEvent.prototype.fixEvent = function () {
var event = this
if (event.which == null && event.type.indexOf('key') === 0) {
event.which = event.charCode != null ? <span class="branch-0 cbranch-skip" title="branch not covered" >event.charCode </span>: event.keyCode
}
if (rmouseEvent.test(event.type) && !('pageX' in event)) {
var DOC = event.target.ownerDocument || <span class="branch-1 cbranch-skip" title="branch not covered" >document</span>
var box = DOC.compatMode === 'BackCompat' ? <span class="branch-0 cbranch-skip" title="branch not covered" >DOC.body </span>: DOC.documentElement
event.pageX = event.clientX + (box.scrollLeft >> 0) - (box.clientLeft >> 0)
event.pageY = event.clientY + (box.scrollTop >> 0) - (box.clientTop >> 0)
event.wheelDeltaY = ~~event.wheelDelta
event.wheelDeltaX = 0
}
}
//针对IE6-8修正input
/* istanbul ignore if */
<span class="skip-if-branch" title="if path not taken" >I</span>if (!('oninput' in document.createElement('input'))) {
<span class="cstat-skip" title="statement not covered" > eventHooks.input = {</span>
type: 'propertychange',
fix: <span class="fstat-skip" title="function not covered" >function (elem, fn) {</span>
<span class="cstat-skip" title="statement not covered" > return <span class="fstat-skip" title="function not covered" >function (e) {</span></span>
<span class="cstat-skip" title="statement not covered" > if (e.propertyName === 'value') {</span>
<span class="cstat-skip" title="statement not covered" > e.type = 'input'</span>
<span class="cstat-skip" title="statement not covered" > return fn.apply(this, arguments)</span>
}
}
}
}
}
</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Tue Dec 13 2016 18:10:11 GMT+0800 (CST)
</div>
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
if (typeof prettyPrint === 'function') {
prettyPrint();
}
};
</script>
<script src="../../sorter.js"></script>
</body>
</html>