Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save catrope/9945606 to your computer and use it in GitHub Desktop.
Fixes for nullable selection (VE-MW)
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 40cd5c4..cfe5584 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -715,11 +715,14 @@ ve.init.mw.ViewPageTarget.prototype.onToolbarMetaButtonClick = function () {
* @param {ve.dm.Transaction} transaction
*/
ve.init.mw.ViewPageTarget.prototype.checkForWikitextWarning = function () {
- var text, doc = this.surface.getView().getDocument(),
+ var text, node, doc = this.surface.getView().getDocument(),
selection = this.surface.getModel().getSelection(),
- node = doc.getNodeFromOffset( selection.start ),
textMatches,
viewPageTarget = this;
+ if ( !selection ) {
+ return;
+ }
+ node = doc.getNodeFromOffset( selection.start );
if ( !( node instanceof ve.ce.ContentBranchNode ) ) {
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment