Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/73952
Change subject: Handle backspace correctly when in a root slug
......................................................................
Handle backspace correctly when in a root slug
Test case:
* '<dl><dd>Foo</dd></dl>'
* Press backspace whilst in the slug after the DL
This still doesn't fix the case when the slug is not in the root,
e.g. a nested DL.
Bug: 50076
Change-Id: Ib89706c8717d13829bf89e44c4fb39e16a00821e
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 17 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/52/73952/1
diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 2d0778f..0c7c8dc 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -1264,23 +1264,28 @@
endNodeData = this.documentView.model.getData(
endNode.model.getRange() );
nodeToDelete = endNode;
nodeToDelete.traverseUpstream( function ( node ) {
- if ( node.getParent().children.length === 1 ) {
- nodeToDelete = node.getParent();
+ var parent = node.getParent();
+ if ( !parent ) {
+ nodeToDelete = null;
+ } else if ( parent.children.length === 1 ) {
+ nodeToDelete = parent;
return true;
} else {
return false;
}
} );
- this.model.change(
- [
- ve.dm.Transaction.newFromRemoval(
- this.documentView.model,
nodeToDelete.getModel().getOuterRange()
- ),
- ve.dm.Transaction.newFromInsertion(
- this.documentView.model,
rangeToRemove.start, endNodeData
- )
- ]
- );
+ if ( nodeToDelete ) {
+ this.model.change(
+ [
+ ve.dm.Transaction.newFromRemoval(
+ this.documentView.model,
nodeToDelete.getModel().getOuterRange()
+ ),
+ ve.dm.Transaction.newFromInsertion(
+ this.documentView.model,
rangeToRemove.start, endNodeData
+ )
+ ]
+ );
+ }
}
this.model.change( null, new ve.Range( rangeToRemove.start ) );
this.surfaceObserver.clear();
--
To view, visit https://gerrit.wikimedia.org/r/73952
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib89706c8717d13829bf89e44c4fb39e16a00821e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits