Don't drop annotated comments in wrappers

HTML like <td><span>Foo<!--bar--></span></td> would lose the comment
when converting to linmod, and so we'd drop the comment when converting
back to HTML.

This happened because we were queueing up meta items to possibly move
them and their whitespace out of the wrapper paragraph even if we were
inside of an annotation and there was no way we could move things out
at all. The fix is simply to detect these case and not queue up meta
items in that case.

[12:11]	marktraceur	Let the comments hit the floor, let the comments hit the floor
[12:11]	marktraceur	(to the tune of the Drowning Pool "Let the Bodies Hit the Floor")

Bug: 50071
Change-Id: I5a844e2e0655bc1db152b3805718324ca0bb04df
This commit is contained in:
Roan Kattouw 2013-06-25 12:29:58 -07:00
parent d31918d145
commit f9e698db22
2 changed files with 43 additions and 1 deletions

View file

@ -844,7 +844,9 @@ ve.dm.Converter.prototype.getDataFromDomRecursion = function ( domElement, wrapp
childDataElements[0].annotations = context.annotations.getIndexes().slice();
}
if ( context.inWrapper ) {
// Queue wrapped meta items only if it's actually possible for us to move them out
// of the wrapper
if ( context.inWrapper && context.canCloseWrapper ) {
wrappedMetaItems = wrappedMetaItems.concat( childDataElements );
if ( wrappedWhitespace !== '' ) {
data.splice( wrappedWhitespaceIndex, wrappedWhitespace.length );

View file

@ -1611,6 +1611,46 @@ ve.dm.example.domToDataCases = {
{ 'type': '/internalList' }
]
},
'annotated metadata in a wrapper': {
'html': '<body><b><!--foo-->bar<!--baz-->quux<!--whee--></b></body>',
'data': [
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
{
'type': 'alienMeta',
'annotations': [ ve.dm.example.bold ],
'attributes': {
'domElements': $( '<!--foo-->' ).toArray()
}
},
{ 'type': '/alienMeta' },
[ 'b', [ ve.dm.example.bold ] ],
[ 'a', [ ve.dm.example.bold ] ],
[ 'r', [ ve.dm.example.bold ] ],
{
'type': 'alienMeta',
'annotations': [ ve.dm.example.bold ],
'attributes': {
'domElements': $( '<!--baz-->' ).toArray()
}
},
{ 'type': '/alienMeta' },
[ 'q', [ ve.dm.example.bold ] ],
[ 'u', [ ve.dm.example.bold ] ],
[ 'u', [ ve.dm.example.bold ] ],
[ 'x', [ ve.dm.example.bold ] ],
{
'type': 'alienMeta',
'annotations': [ ve.dm.example.bold ],
'attributes': {
'domElements': $( '<!--whee-->' ).toArray()
}
},
{ 'type': '/alienMeta' },
{ 'type': '/paragraph' },
{ 'type': 'internalList' },
{ 'type': '/internalList' }
]
},
'wrapping of bare content': {
'html': '<body>abc</body>',
'data': [