File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1+ const HANDLER = 'c_clickaway_handler'
2+
3+ function setListeners ( el , binding , vnode ) {
4+ const callback = binding . value
5+ if ( typeof callback !== 'function' ) {
6+ return
7+ }
8+ el [ HANDLER ] = ( e ) => el . contains ( e . target ) || callback . call ( vnode . context , e )
9+ document . documentElement . addEventListener ( binding . arg || 'click' , el [ HANDLER ] )
10+ }
11+
12+ function unsetListeners ( el , binding ) {
13+ document . documentElement . removeEventListener ( binding . arg || 'click' , el [ HANDLER ] )
14+ delete el [ HANDLER ]
15+ }
16+
17+ export default {
18+ bind : setListeners ,
19+ update : ( el , binding , vnode ) => {
20+ if ( binding . value !== binding . oldValue ) {
21+ unsetListeners ( el , binding )
22+ setListeners ( el , binding , vnode )
23+ }
24+ } ,
25+ unbind : unsetListeners
26+ }
Original file line number Diff line number Diff line change 1+ import CClickaway from './CClickaway'
2+ import CEmitRootEvent from './CEmitRootEvent'
13import CPopover from './CPopover'
24import CTooltip from './CTooltip'
3- import CEmitRootEvent from './CEmitRootEvent'
45
5- export {
6+ export {
7+ CClickaway ,
8+ CEmitRootEvent ,
69 CPopover ,
7- CTooltip ,
8- CEmitRootEvent
10+ CTooltip
911}
You can’t perform that action at this time.
0 commit comments