Fix for check if data is balanced

Previous check wouldn't make sense, cause the last offset in the data
could be that one that makes data balanced (and j is increased always
after iteration).


Change-Id: Ie9498d0ac9e3417d09b8b3043bf3281e7dfbf9db
This commit is contained in:
Inez Korczyński 2013-05-20 16:54:03 -07:00
parent c1477bc1da
commit 02d522500c
3 changed files with 21 additions and 1 deletions

View file

@ -26,6 +26,8 @@ ve.inheritClass( ve.dm.MWBlockImageNode, ve.dm.BranchNode );
ve.dm.MWBlockImageNode.static.name = 'MWblockimage';
ve.dm.MWBlockImageNode.static.storeHtmlAttributes = [ 'data-parsoid' ];
ve.dm.MWBlockImageNode.static.handlesOwnChildren = true;
ve.dm.MWBlockImageNode.static.childNodeTypes = [ 'MWimagecaption' ];

View file

@ -973,7 +973,7 @@ ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) {
}
j++;
}
if ( j >= data.length ) {
if ( depth !== 0 ) {
throw new Error( 'Unbalanced data: looking for closing /' +
dataElement.type );
}

View file

@ -3122,6 +3122,24 @@ ve.dm.example.domToDataCases = {
{ 'type': '/paragraph' },
{ 'type': '/div' }
]
},
'thumb image': {
'html': '<body><figure typeof="mw:Image/Thumb"><a rel="mw:thumb" href="Foo"><img src="Bar" width="1" height="2" resource="FooBar"></a></figure></body>',
'data': [
{
'type': 'MWblockimage',
'attributes': {
'type': 'thumb',
'align': 'right',
'href': 'Foo',
'src': 'Bar',
'width': '1',
'height': '2',
'resource': 'FooBar'
}
},
{ 'type': '/MWblockimage' }
]
}
};