mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Fix bug where inline nodes didn't trigger wrapping
When encountering an inline node (i.e. content node that's not a text node) within a branch node that's not a content branch node, the converter should start a wrapper. But it doesn't do this, it only opens wrappers for text nodes and annotations. Fixed this in the converter, added a test for it, and fixed an existing test that asserted the broken behavior. Change-Id: I6e143e21e68b68f0d85b8772e24a2d3a5d465410
This commit is contained in:
parent
626257fb39
commit
57ad316988
|
@ -517,6 +517,9 @@ ve.dm.Converter.prototype.getDataFromDom = function ( domElement, annotations, d
|
|||
// but only if childDataElement is a non-content element
|
||||
if ( context.wrapping && context.canCloseWrapper && !childIsContent ) {
|
||||
stopWrapping();
|
||||
} else if ( !context.wrapping && !context.expectingContent && childIsContent ) {
|
||||
startWrapping();
|
||||
prevElement = wrappingParagraph;
|
||||
}
|
||||
if ( this.nodeFactory.canNodeHaveChildren( childDataElement.type ) ) {
|
||||
// Append child element data
|
||||
|
|
|
@ -35,7 +35,7 @@ QUnit.test( 'getDomElementFromDataElement', 20, function ( assert ) {
|
|||
}
|
||||
} );
|
||||
|
||||
QUnit.test( 'getDataFromDom', 48, function ( assert ) {
|
||||
QUnit.test( 'getDataFromDom', 49, function ( assert ) {
|
||||
var msg,
|
||||
cases = ve.dm.example.domToDataCases;
|
||||
|
||||
|
@ -51,7 +51,7 @@ QUnit.test( 'getDataFromDom', 48, function ( assert ) {
|
|||
}
|
||||
} );
|
||||
|
||||
QUnit.test( 'getDomFromData', 52, function ( assert ) {
|
||||
QUnit.test( 'getDomFromData', 53, function ( assert ) {
|
||||
var msg,
|
||||
cases = ve.dm.example.domToDataCases;
|
||||
|
||||
|
|
|
@ -673,8 +673,10 @@ ve.dm.example.domToDataCases = {
|
|||
'image': {
|
||||
'html': '<img src="image.png">',
|
||||
'data': [
|
||||
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
|
||||
{ 'type': 'image', 'attributes' : { 'html/src' : 'image.png' } },
|
||||
{ 'type' : '/image' }
|
||||
{ 'type' : '/image' },
|
||||
{ 'type': '/paragraph' }
|
||||
]
|
||||
},
|
||||
'paragraph with alienInline inside': {
|
||||
|
@ -757,6 +759,17 @@ ve.dm.example.domToDataCases = {
|
|||
{ 'type': '/paragraph' }
|
||||
]
|
||||
},
|
||||
'wrapping of bare content starting with inline node': {
|
||||
'html': '<img src="foo.jpg">12',
|
||||
'data': [
|
||||
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
|
||||
{ 'type': 'image', 'attributes': { 'html/src': 'foo.jpg' } },
|
||||
{ 'type': '/image' },
|
||||
'1',
|
||||
'2',
|
||||
{ 'type': '/paragraph' }
|
||||
]
|
||||
},
|
||||
'wrapping of bare content with inline alien': {
|
||||
'html': '1<tt class="bar">baz</tt>2',
|
||||
'data': [
|
||||
|
|
Loading…
Reference in a new issue