Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77274
Change subject: ve.ui.Toolbar: Use closure instead of ve.bind for event handlers
......................................................................
ve.ui.Toolbar: Use closure instead of ve.bind for event handlers
Code speaks for itself, see also bug 52441.
Though not introduced by 14343c7bf7, that made the bug worse.
Bug: 52441
Change-Id: Ie2b80b22df03eb563de8812a47fb25152527e786
---
M modules/ve/ui/ve.ui.Toolbar.js
1 file changed, 15 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/74/77274/1
diff --git a/modules/ve/ui/ve.ui.Toolbar.js b/modules/ve/ui/ve.ui.Toolbar.js
index 71c2c88..869405d 100644
--- a/modules/ve/ui/ve.ui.Toolbar.js
+++ b/modules/ve/ui/ve.ui.Toolbar.js
@@ -19,6 +19,7 @@
* @cfg {boolean} [shadow] Add a shadow below the toolbar
*/
ve.ui.Toolbar = function VeUiToolbar( surface, options ) {
+ var toolbar = this;
// Configuration initialization
options = options || {};
@@ -40,11 +41,22 @@
this.$surfaceView = null;
this.elementOffset = null;
this.windowEvents = {
- 'resize': ve.bind( this.onWindowResize, this ),
- 'scroll': ve.bind( this.onWindowScroll, this )
+ // jQuery puts a guid on our prototype function when we use
ve.bind,
+ // we don't want that because that means calling $window.off(
toolbarB.windowEvents )
+ // will effectively also unbind toolbarA.windowEvents as they
would share a guid.
+ // Though jQuery does not share the reference (both A and B
have the correct context
+ // bound), it does unbind them. Use a regular closure instead.
+ 'resize': function () {
+ return toolbar.onWindowResize.apply( toolbar, arguments
);
+ },
+ 'scroll': function () {
+ return toolbar.onWindowScroll.apply( toolbar, arguments
);
+ }
};
this.surfaceViewEvents = {
- 'keyup': ve.bind( this.onSurfaceViewKeyUp, this )
+ 'keyup': function () {
+ return toolbar.onSurfaceViewKeyUp.apply( toolbar,
arguments );
+ }
};
// Events
--
To view, visit https://gerrit.wikimedia.org/r/77274
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2b80b22df03eb563de8812a47fb25152527e786
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits