Open CarterLi opened 3 years ago
Why was it closed?
addEvent is implemented as
export function addEvent (el, event, handler) {
if (!el) {
return
}
if (el.attachEvent) {
el.attachEvent('on' + event, handler)
} else if (el.addEventListener) {
el.addEventListener(event, handler, true)
} else {
el['on' + event] = handler
}
}
for addEvent(document.documentElement, 'touchend touchcancel', this.deselect)
, you got
document.documentElement.attachEvent('ontouchend touchcancel', this.deselect)
document.documentElement.addEventListener('touchend touchcancel', this.deselect, true)
document.documentElement['ontouchend touchcancel'] = this.deselect
This was rediculous. addEventListener does NEVER support such a usage. If you do that, you end up adding a event listener named touchend touchcancel
which is NOT touchend
nor touchcancel
and none of touchend
and touchcancel
will be fired
Open your F12, input document.documentElement.addEventListener('mousemove mousedown', console.log)
and try it yourself
Note: jQuery.on does support space-separated event types. But addEventListener is not JQuery
In addition, you seem try to support IE8
el.attachEvent('on' + event, handler)
But Vue ( including Vue 2 ) does NOT support IE8. Therefore the code is useless.
Well, it wasn't so hard to explain what you meant with that first comment, wasn't it? Why didn't you do that in the first place?
https://github.com/mauricius/vue-draggable-resizable/blob/cb43b89da98f733dc2637668e9f9cdbf5dc2bc82/src/components/vue-draggable-resizable.vue#L302