Skip to content

Instantly share code, notes, and snippets.

@catrope
Created April 2, 2014 23:43
Show Gist options
  • Select an option

  • Save catrope/9945583 to your computer and use it in GitHub Desktop.

Select an option

Save catrope/9945583 to your computer and use it in GitHub Desktop.
Fixes for nullable selection (VE core)
diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js
index 6e07f70..8ecd560 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -525,7 +525,7 @@ ve.dm.Surface.prototype.changeInternal = function ( transactions, selection, ski
( !selectionBefore || !selectionBefore.equals( selectionAfter ) ) &&
( selectionAfter && selectionAfter.equals( this.selection ) )
) {
- this.emit( 'select', this.selection.clone() );
+ this.emit( 'select', this.selection && this.selection.clone() );
}
if ( contextChange ) {
@@ -549,8 +549,8 @@ ve.dm.Surface.prototype.breakpoint = function () {
if ( this.newTransactions.length > 0 ) {
this.undoStack.push( {
'transactions': this.newTransactions,
- 'selection': this.selection.clone(),
- 'selectionBefore': this.selectionBefore.clone()
+ 'selection': this.selection && this.selection.clone(),
+ 'selectionBefore': this.selectionBefore && this.selectionBefore.clone()
} );
this.newTransactions = [];
this.emit( 'history' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment