mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Math Node UI (Bug Fix)
Fixed two bugs found after merging: 1. Opened the Math node inspector without editing anything, then clicked somewhere else on the page, it crashed. 2. Similarly, opened the Math node inspector without editing anything, then clicked the "Cancel" button to cancel the edit, it crashed. Both of these problems are fixed by this patch. The issue was with using the getFocusedNode() in the inspector onClose function to save changes. Also, I included some minor changes relating to the last code review. =D Change-Id: I6e200f2a228b71dc5af5aa9843c461f43b926f8d
This commit is contained in:
parent
4c85442047
commit
8eadcb0a26
|
@ -57,11 +57,13 @@ ve.ui.MWMathInspector.prototype.initialize = function () {
|
|||
*/
|
||||
ve.ui.MWMathInspector.prototype.onOpen = function () {
|
||||
|
||||
var src = this.surface.getView().getFocusedNode().getModel().getAttribute( 'extsrc' );
|
||||
|
||||
// Parent method
|
||||
ve.ui.Inspector.prototype.onOpen.call( this );
|
||||
|
||||
this.mathNode = this.surface.getView().getFocusedNode();
|
||||
|
||||
var src = this.mathNode.getModel().getAttribute( 'extsrc' );
|
||||
|
||||
// Wait for animation to complete
|
||||
setTimeout( ve.bind( function () {
|
||||
// Setup input text
|
||||
|
@ -76,16 +78,16 @@ ve.ui.MWMathInspector.prototype.onOpen = function () {
|
|||
* @param {string} action Action that caused the window to be closed
|
||||
*/
|
||||
ve.ui.MWMathInspector.prototype.onClose = function ( action ) {
|
||||
|
||||
var newsrc = this.input.getValue(),
|
||||
surfaceModel = this.surface.getModel();
|
||||
|
||||
// Parent method
|
||||
ve.ui.Inspector.prototype.onClose.call( this, action );
|
||||
|
||||
var newsrc = this.input.getValue(),
|
||||
surfaceModel = this.surface.getModel(),
|
||||
mathNode = this.surface.getView().getFocusedNode().getModel();
|
||||
|
||||
surfaceModel.change(
|
||||
ve.dm.Transaction.newFromAttributeChanges(
|
||||
surfaceModel.getDocument(), mathNode.getOuterRange().start, { 'extsrc': newsrc }
|
||||
surfaceModel.getDocument(), this.mathNode.getOuterRange().start, { 'extsrc': newsrc }
|
||||
)
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue