mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
Fix a weird whitespace stripping bug
In HTML like <td>Foo <b>Bar</b></td>, the space would be stripped and registered as trailing whitespace in the <td>, so it wouldn't be visible in the editor and would be inserted after the </b> on the way out. Thanks to Subbu for reporting this. This case was kind of ridiculous and we're lucky the JRuby article contained it. To trigger the bug, you had to have: * a table cell * containing unwrapped content * consisting of ** some text ** whitespace ** open annotation (bold in my example, link in Subbu's case) ** text ** close annotation ** and nothing else Change-Id: I2b83f02764b311a32a50956d4c8930a9394e91a4
This commit is contained in:
parent
116321afe5
commit
2f1ee49213
|
@ -462,6 +462,8 @@ ve.dm.Converter.prototype.getDataFromDomRecursion = function ( domElement, wrapp
|
||||||
data = data.concat(
|
data = data.concat(
|
||||||
this.getDataFromDomRecursion( childDomElement, undefined, childAnnotations )
|
this.getDataFromDomRecursion( childDomElement, undefined, childAnnotations )
|
||||||
);
|
);
|
||||||
|
// Clear wrapped whitespace
|
||||||
|
wrappedWhitespace = '';
|
||||||
} else {
|
} else {
|
||||||
// Node or meta item
|
// Node or meta item
|
||||||
if ( modelClass.prototype instanceof ve.dm.MetaItem ) {
|
if ( modelClass.prototype instanceof ve.dm.MetaItem ) {
|
||||||
|
|
|
@ -1652,6 +1652,28 @@ ve.dm.example.domToDataCases = {
|
||||||
// comparing DOM trees
|
// comparing DOM trees
|
||||||
'normalizedHtml': '<body>\n<pre>\n\n\n\nFoo\n\n\nBar\n\n\n\n</pre>\n\n\n\n\n</body>'
|
'normalizedHtml': '<body>\n<pre>\n\n\n\nFoo\n\n\nBar\n\n\n\n</pre>\n\n\n\n\n</body>'
|
||||||
},
|
},
|
||||||
|
'whitespace preservation in table cell starting with text and ending with annotation': {
|
||||||
|
'html': '<body><table><tbody><tr><td>Foo <b>Bar</b></td></tr></tbody></table></body>',
|
||||||
|
'data': [
|
||||||
|
{ 'type': 'table' },
|
||||||
|
{ 'type': 'tableSection', 'attributes': { 'style': 'body' } },
|
||||||
|
{ 'type': 'tableRow' },
|
||||||
|
{ 'type': 'tableCell', 'attributes': { 'style': 'data' } },
|
||||||
|
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
|
||||||
|
'F',
|
||||||
|
'o',
|
||||||
|
'o',
|
||||||
|
' ',
|
||||||
|
[ 'B', [ ve.dm.example.bold ] ],
|
||||||
|
[ 'a', [ ve.dm.example.bold ] ],
|
||||||
|
[ 'r', [ ve.dm.example.bold ] ],
|
||||||
|
{ 'type': '/paragraph' },
|
||||||
|
{ 'type': '/tableCell' },
|
||||||
|
{ 'type': '/tableRow' },
|
||||||
|
{ 'type': '/tableSection' },
|
||||||
|
{ 'type': '/table' }
|
||||||
|
]
|
||||||
|
},
|
||||||
'mismatching whitespace data is ignored': {
|
'mismatching whitespace data is ignored': {
|
||||||
'html': null,
|
'html': null,
|
||||||
'data': [
|
'data': [
|
||||||
|
|
Loading…
Reference in a new issue