Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/197968

Change subject: Work around JS errors when editing image properties
......................................................................

Work around JS errors when editing image properties

When modifying an image, its caption is blanked and then reinserted.
The clearing transaction causes an 'update' event to be emitted on
the image node, which causes GeneratedContentNode to do things and
emit rerender, which causes FocusableNode to call updateDimensions().

However, at the time updateDimensions() is called, the selection
hasn't yet been updated for the transaction, and so out of bounds
exceptions can occur. A proper solution would be to ensure that such
functions aren't called from event handlers that run when the selection
isn't in sync with the document, but for now we're working around this
by ensuring that getRelatedSources() doesn't attempt to look at the
selection on a cache hit, which fixes the immediate problem because
the problematic cases always happen to be cache hits.

Bug: T93204
Change-Id: I610018a6828deb1eafdea4fe82e904c0c186a483
---
M src/ui/ve.ui.Context.js
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/68/197968/1

diff --git a/src/ui/ve.ui.Context.js b/src/ui/ve.ui.Context.js
index ddf694d..b855e5d 100644
--- a/src/ui/ve.ui.Context.js
+++ b/src/ui/ve.ui.Context.js
@@ -246,12 +246,12 @@
  *   and the model the item or tool is compatible with
  */
 ve.ui.Context.prototype.getRelatedSources = function () {
-       var i, len, toolClass, items, tools, models,
-               selectedModels = 
this.surface.getModel().getFragment().getSelectedModels();
+       var i, len, toolClass, items, tools, models, selectedModels;
 
        if ( !this.relatedSources ) {
                this.relatedSources = [];
                if ( this.surface.getModel().getSelection() instanceof 
ve.dm.LinearSelection ) {
+                       selectedModels = 
this.surface.getModel().getFragment().getSelectedModels();
                        models = [];
                        items = ve.ui.contextItemFactory.getRelatedItems( 
selectedModels );
                        for ( i = 0, len = items.length; i < len; i++ ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/197968
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I610018a6828deb1eafdea4fe82e904c0c186a483
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to