mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
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:
parent
d31918d145
commit
f9e698db22
|
@ -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 );
|
||||
|
|
|
@ -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': [
|
||||
|
|
Loading…
Reference in a new issue