Merge pull request #749 from pelonpelon/patch-19
allow m.withAttr callback to determine its own `this` [non-breaking]
This commit is contained in:
commit
a9ab36388b
2 changed files with 10 additions and 2 deletions
|
|
@ -851,11 +851,12 @@ var m = (function app(window, undefined) {
|
|||
else m.endComputation();
|
||||
}
|
||||
|
||||
m.withAttr = function(prop, withAttrCallback) {
|
||||
m.withAttr = function(prop, withAttrCallback, callbackThis) {
|
||||
return function(e) {
|
||||
e = e || event;
|
||||
var currentTarget = e.currentTarget || this;
|
||||
withAttrCallback(prop in currentTarget ? currentTarget[prop] : currentTarget.getAttribute(prop));
|
||||
var _this = callbackThis || this;
|
||||
withAttrCallback.call(_this, prop in currentTarget ? currentTarget[prop] : currentTarget.getAttribute(prop));
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue