Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/71270
Change subject: Fix bug where whitespace in an empty node was doubled
......................................................................
Fix bug where whitespace in an empty node was doubled
<table>\n\n</table> round-tripped to <table>\n\n\n\n</table> because
we would store '\n\n' in both the innerPre and innerPost fields.
Fixed by not setting innerPost if the element is empty.
Change-Id: I0393bfaf9793fdebc8fff72c8760113fa69bb2bd
---
M modules/ve/dm/ve.dm.Converter.js
M modules/ve/test/dm/ve.dm.example.js
2 files changed, 13 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/70/71270/1
diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js
index 47ed400..6586bb6 100644
--- a/modules/ve/dm/ve.dm.Converter.js
+++ b/modules/ve/dm/ve.dm.Converter.js
@@ -883,12 +883,14 @@
// Close element
if ( wrapperElement ) {
- data.push( { 'type': '/' + wrapperElement.type } );
// Add the whitespace after the last child to the parent as
innerPost
- if ( nextWhitespace !== '' ) {
+ // But don't do this if the parent is empty, because in that
case we've already put that
+ // whitespace in innerPre
+ if ( nextWhitespace !== '' && data[data.length - 1] !==
wrapperElement ) {
addWhitespace( wrapperElement, 2, nextWhitespace );
nextWhitespace = '';
}
+ data.push( { 'type': '/' + wrapperElement.type } );
}
// Don't return an empty document
if ( context.branchType === 'document' && data.length === 0 &&
!annotationSet ) {
diff --git a/modules/ve/test/dm/ve.dm.example.js
b/modules/ve/test/dm/ve.dm.example.js
index 3525253..a7dae8d 100644
--- a/modules/ve/test/dm/ve.dm.example.js
+++ b/modules/ve/test/dm/ve.dm.example.js
@@ -2044,6 +2044,15 @@
{ 'type': '/internalList' }
]
},
+ 'whitespace preservation in empty branch node': {
+ 'html': '<body><table>\n\n</table></body>',
+ 'data': [
+ { 'type': 'table', 'internal': { 'whitespace': [
undefined, '\n\n' ] } },
+ { 'type': '/table' },
+ { 'type': 'internalList' },
+ { 'type': '/internalList' }
+ ]
+ },
'mismatching whitespace data is ignored': {
'html': null,
'data': [
--
To view, visit https://gerrit.wikimedia.org/r/71270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0393bfaf9793fdebc8fff72c8760113fa69bb2bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits