From 069eefe34309f6c6cd4ea66dfefd06669fff6cdc Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 26 Sep 2013 17:38:36 -0700 Subject: [PATCH] Fix JS error in ve.ui.ClippableContainer Sometimes, .clip() would be called when clipping had already been disabled again, and accessing this.$clippableContainer would cause an error. This happened to me when typing quickly in MWLinkInspector. This probably happens when enabling and disabling clipping right after each other in response to the same event, such that the setTimeout() for the initial clip is run after clipping has already been disabled. Change-Id: I0f85ea5f10955188bae51160e1c88eca858ea1bf --- modules/ve/ui/elements/ve.ui.ClippableElement.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ve/ui/elements/ve.ui.ClippableElement.js b/modules/ve/ui/elements/ve.ui.ClippableElement.js index d022b8dc1d..ca91a5b16a 100644 --- a/modules/ve/ui/elements/ve.ui.ClippableElement.js +++ b/modules/ve/ui/elements/ve.ui.ClippableElement.js @@ -90,6 +90,11 @@ ve.ui.ClippableElement.prototype.isClipped = function () { * @chainable */ ve.ui.ClippableElement.prototype.clip = function () { + if ( !this.clipping ) { + // this.$clippableContainer and this.$clippableWindow are null, so the below will fail + return this; + } + var buffer = 10, cOffset = this.$clippable.offset(), ccOffset = this.$clippableContainer.offset() || { 'top': 0, 'left': 0 },