0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Standardise white space in public getHTML method.

Add in <br>s where required in Opera and IE.
This commit is contained in:
Neil Jenkins 2011-11-03 17:37:32 +11:00
parent 28c9ab10a9
commit f15a57cba6
2 changed files with 24 additions and 5 deletions

File diff suppressed because one or more lines are too long

View file

@ -21,6 +21,7 @@ document.addEventListener( 'DOMContentLoaded', function () {
body = doc.body; body = doc.body;
var isOpera = !!win.opera; var isOpera = !!win.opera;
var useTextFixer = isOpera || !!win.ie;
// --- DOM Sugar --- // --- DOM Sugar ---
@ -1204,7 +1205,28 @@ document.addEventListener( 'DOMContentLoaded', function () {
return doc; return doc;
}, },
getHTML: getHTML, getHTML: function () {
var brs = [],
node, fixer, html, l;
if ( useTextFixer ) {
node = body;
while ( node = node.getNextBlock() ) {
if ( !node.textContent && !node.querySelector( 'BR' ) ) {
fixer = createElement( 'BR' );
node.appendChild( fixer );
brs.push( fixer );
}
}
}
html = getHTML();
if ( useTextFixer ) {
l = brs.length;
while ( l-- ) {
brs[l].detach();
}
}
return html;
},
setHTML: function ( html ) { setHTML: function ( html ) {
// Extract styles to insert into <head> // Extract styles to insert into <head>
var styles = []; var styles = [];
@ -1237,9 +1259,6 @@ document.addEventListener( 'DOMContentLoaded', function () {
node.fixCursor(); node.fixCursor();
} }
// Normalise
frag.normalize();
// Remove existing body children // Remove existing body children
while ( child = body.lastChild ) { while ( child = body.lastChild ) {
body.removeChild( child ); body.removeChild( child );