8000 fix for wrappedHandler · daniiell3/vuejs.org@3a2779e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a2779e

Browse files
committed
fix for wrappedHandler
1 parent 8ee7ce1 commit 3a2779e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/v2/cookbook/clickoutside-directive.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ Vue.directive('clickoutside', {
7777
const handler = binding.value
7878

7979
// create a named function for the handler
80-
function handler(event) {
80+
function wrappedHandler(event) {
8181
const target = event.target
8282
if (!el.contains(target) && el !== target) {
8383
handler(event)
8484
}
8585
}
8686

8787
// and save it in a property on the element
88-
el.__vueClickOutside__ = handler
88+
el.__vueClickOutside__ = wrappedHandler
8989

9090
setTimeout(function() {
91-
document.addEventListener('click', handler)
91+
document.addEventListener('click', wrappedHandler)
9292
}, 0)
9393
},
9494

@@ -117,8 +117,8 @@ var handlerCache = new Map()
117117
Vue.directive('clickoutside', {
118118
bind(el, binding) {
119119
// ...
120-
// el.__vueClickOutside__ = handler
121-
handlerCache.set(el, handler)
120+
// el.__vueClickOutside__ = wrappedHandler
121+
handlerCache.set(el, wrappedHandler)
122122
// ...
123123
},
124124
unbind(el) {

0 commit comments

Comments
 (0)
0