From 328dd8e21ff29bcd38013a7a1a3919df397358d5 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 9 May 2013 20:22:12 +0100 Subject: [PATCH] Whitespace between unwrapped inline nodes assigned to paragraph In stopWrapping we assign any left over whitespace to the paragraph in position 3, however we weren't clearing this whitespace buffer if an inline content node followed it. Change-Id: I8b3ee3915044abd6bafda386430bf7f992ca4aa8 --- modules/ve/dm/ve.dm.Converter.js | 6 ++++++ modules/ve/test/dm/ve.dm.example.js | 32 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js index dd16935b47..05425e8c72 100644 --- a/modules/ve/dm/ve.dm.Converter.js +++ b/modules/ve/dm/ve.dm.Converter.js @@ -590,6 +590,12 @@ ve.dm.Converter.prototype.getDataFromDomRecursion = function ( domElement, wrapp } } + // If we're inserting content into a wrapper, any wrappedWhitespace + // up to this point can be considered dealt with + if ( context.inWrapper && childIsContent ) { + wrappedWhitespace = ''; + } + // Annotate child if ( childIsContent && !context.annotations.isEmpty() ) { childDataElements[0].annotations = context.annotations.getIndexes().slice(); diff --git a/modules/ve/test/dm/ve.dm.example.js b/modules/ve/test/dm/ve.dm.example.js index 1dc2f20a03..378d4c5274 100644 --- a/modules/ve/test/dm/ve.dm.example.js +++ b/modules/ve/test/dm/ve.dm.example.js @@ -1621,6 +1621,38 @@ ve.dm.example.domToDataCases = { { 'type': '/paragraph' } ] }, + 'whitespace between unwrapped inline nodes': { + 'html': + '' + + 'c d\ne' + + '', + 'data': [ + { + 'type': 'paragraph', + 'internal': { + 'generated': 'wrapper' + } + }, + { + 'type': 'MWentity', + 'attributes': { 'character': 'c', 'html/0/typeof': 'mw:Entity' } + }, + { 'type': '/MWentity' }, + ' ', + { + 'type': 'MWentity', + 'attributes': { 'character': 'd', 'html/0/typeof': 'mw:Entity' } + }, + { 'type': '/MWentity' }, + '\n', + { + 'type': 'MWentity', + 'attributes': { 'character': 'e', 'html/0/typeof': 'mw:Entity' } + }, + { 'type': '/MWentity' }, + { 'type': '/paragraph' }, + ] + }, 'whitespace preservation in headings': { 'html': '

Foo

Bar

Baz

Quux

', 'data': [