I need your help.
I have 2 functions:
addMoveListeners: function(e) {
e = e || window.event;
// Binging context to function move
moveListener = MYAPP.move.bind(e.target.parentElement);
//
if (e.target.classList.contains('move')){
document.addEventListener('mousemove', moveListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
resizeListener = MYAPP.resize.bind(e.target.parentElement);
if (e.target.classList.contains('resize')){
document.addEventListener('mousemove', resizeListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
return false;
},
and this:
removeListener: function(e){
e = e || window.event;
//Here I want get element from function
console.dir(resizeListener);
// Function stores it in [[BoundThis]]
document.removeEventListener('mousemove', resizeListener, false);
document.removeEventListener('mouseup', MYAPP.removeListener, false);
document.removeEventListener('mousemove', moveListener, false);
document.removeEventListener('mouseup', MYAPP.moveListener, false);
},
How can I get property [[BoundThis]] from function resizeListener without execution.
I need your help.
I have 2 functions:
addMoveListeners: function(e) {
e = e || window.event;
// Binging context to function move
moveListener = MYAPP.move.bind(e.target.parentElement);
//
if (e.target.classList.contains('move')){
document.addEventListener('mousemove', moveListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
resizeListener = MYAPP.resize.bind(e.target.parentElement);
if (e.target.classList.contains('resize')){
document.addEventListener('mousemove', resizeListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
return false;
},
and this:
removeListener: function(e){
e = e || window.event;
//Here I want get element from function
console.dir(resizeListener);
// Function stores it in [[BoundThis]]
document.removeEventListener('mousemove', resizeListener, false);
document.removeEventListener('mouseup', MYAPP.removeListener, false);
document.removeEventListener('mousemove', moveListener, false);
document.removeEventListener('mouseup', MYAPP.moveListener, false);
},
How can I get property [[BoundThis]] from function resizeListener without execution.
Share Improve this question edited Dec 10, 2014 at 13:37 trunkovich asked Dec 10, 2014 at 12:46 trunkovichtrunkovich 3272 silver badges10 bronze badges 3 |1 Answer
Reset to default 20You cannot. [[BoundThis]]
is an internal property of bound function objects. It is not programmatically accessible.
You might be able to view it with inspection of the object via console, but to use it in your program logic you will need to write your own version of bind
that exposes this value as a property.
Function.prototype.bind
on the handler -- I suspect the OP wants to get thethis
value that has been bound to the function. – Qantas 94 Heavy Commented Dec 10, 2014 at 13:08