Permalink
Browse files

Opera collapses blocks with just spaces for data

  • Loading branch information...
1 parent 14ee0d0 commit cfe9bea8b31db8e80a24bcf16b251b775520201e @neilj committed Dec 9, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 source/Node.js
View
@@ -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' ) ) {

0 comments on commit cfe9bea

Please sign in to comment.