From 531c04967937ae7bf84c6c0b5ca252beb88f14e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inez=20Korczyn=CC=81ski?= Date: Thu, 16 May 2013 15:29:48 -0700 Subject: [PATCH] Support for nodes that handles their own children in ve.dm.Converter.prototype.getDomSubtreeFromData Change-Id: I784dec71d3f0b23001075234e324a8e06a6cfc6b --- modules/ve/dm/ve.dm.Converter.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js index fbfdbb262c..bae856fee1 100644 --- a/modules/ve/dm/ve.dm.Converter.js +++ b/modules/ve/dm/ve.dm.Converter.js @@ -921,6 +921,7 @@ ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) { var dataSlice, j, depth, handlesOwn = false; + // TODO: Shouldn't be implemented with try..catch cause it makes debugging harder and sacrifice performance. try { handlesOwn = ve.dm.nodeFactory.doesNodeHandleOwnChildren( data[i].type ); } catch ( e ) {} @@ -1225,6 +1226,17 @@ ve.dm.Converter.prototype.getDomSubtreeFromData = function ( data, container ) { ); } } + + // In case of nodes that handles own children ascend to parent node. + // It looks like the solution would be to avoid descending first ( so ascending + // wouldn't be needed ) but note that then code above for handling white spaces + // wouldn't execute correctly. + // TODO: Shouldn't be implemented with try..catch cause it makes debugging harder and sacrifice performance. + try { + if ( ve.dm.nodeFactory.doesNodeHandleOwnChildren( data[i].type ) ) { + domElement = parentDomElement; + } + } catch ( e ) {} } if ( ve.isArray( dataElementOrSlice ) ) {