jenkins-bot has submitted this change and it was merged. Change subject: Fix the newline bunny-hop bug harder ......................................................................
Fix the newline bunny-hop bug harder In I4375f4c07, I fixed a bug where " <meta>\nfoo" would dirty-diff to "\n <meta>foo" in wrapper paragraphs. It turns out this was still broken in the case where the newline was followed by an inline node rather than text: " <meta>\n<span>" was still being dirty-diffed to "\n <meta><span>". This was caused by a special case for when a content node is inserted into a wrapper, in which case wrappedWhitespace is cleared. That's fine and necessary, but in addition to that, we also need to output any buffered meta items and their whitespace, and clear nextWhitespace so we don't later record the previous value of wrappedWhitespace as outer whitespace in the content node's .internal.whitespace array. Bug: 69861 Change-Id: Ie80a98512b350311832a8674fac892b378738df0 --- M src/dm/ve.dm.Converter.js M tests/dm/ve.dm.example.js 2 files changed, 33 insertions(+), 2 deletions(-) Approvals: Jforrester: Looks good to me, but someone else must approve Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/src/dm/ve.dm.Converter.js b/src/dm/ve.dm.Converter.js index a5f19b4..dec875d 100644 --- a/src/dm/ve.dm.Converter.js +++ b/src/dm/ve.dm.Converter.js @@ -762,10 +762,13 @@ } } - // If we're inserting content into a wrapper, any wrappedWhitespace - // up to this point can be considered dealt with + // If we're inserting content into a wrapper, any wrapped whitespace and meta + // items up until this point are here to stay if ( context.inWrapper && childIsContent ) { + outputWrappedMetaItems( 'restore' ); wrappedWhitespace = ''; + // Don't record the wrapped whitespace as the child node's outer whitespace + nextWhitespace = ''; } // Annotate child diff --git a/tests/dm/ve.dm.example.js b/tests/dm/ve.dm.example.js index 8200da8..8de75c8 100644 --- a/tests/dm/ve.dm.example.js +++ b/tests/dm/ve.dm.example.js @@ -2364,6 +2364,34 @@ { type: '/internalList' } ] }, + 'whitespace surrounding metadata in a wrapper followed by inline node': { + body: '<b>Foo</b> <meta />\n<span rel="ve:Alien"></span>', + data: [ + { type: 'paragraph', internal: { generated: 'wrapper' } }, + [ 'F', [ ve.dm.example.bold ] ], + [ 'o', [ ve.dm.example.bold ] ], + [ 'o', [ ve.dm.example.bold ] ], + ' ', + { + type: 'alienMeta', + attributes: { + domElements: $( '<meta />' ).toArray() + } + }, + { type: '/alienMeta' }, + '\n', + { + type: 'alienInline', + attributes: { + domElements: $( '<span rel="ve:Alien"></span>' ).toArray() + } + }, + { type: '/alienInline' }, + { type: '/paragraph' }, + { type: 'internalList' }, + { type: '/internalList' } + ] + }, 'whitespace preservation in empty branch node': { body: '<table>\n\n</table>', data: [ -- To view, visit https://gerrit.wikimedia.org/r/155634 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie80a98512b350311832a8674fac892b378738df0 Gerrit-PatchSet: 4 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits