From cfe9bea8b31db8e80a24bcf16b251b775520201e Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Fri, 9 Dec 2011 13:30:58 +1100 Subject: [PATCH] Opera collapses blocks with just spaces for data --- source/Node.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/Node.js b/source/Node.js index 8d207a0..ae224e1 100644 --- a/source/Node.js +++ b/source/Node.js @@ -385,8 +385,16 @@ implement( Element, { } el = child; } - if ( el.isLeaf() && el.nodeType !== TEXT_NODE ) { - el.parentNode.insertBefore( doc.createTextNode( '' ), el ); + if ( el.isLeaf() ) { + if ( el.nodeType !== TEXT_NODE ) { + el.parentNode.insertBefore( + doc.createTextNode( '' ), el ); + } + // Opera will collapse the block element if it contains + // just spaces (but not if it contains no data at all). + else if ( /^ +$/.test( el.data ) ) { + el.data = ''; + } } } else if ( !el.querySelector( 'BR' ) ) {