Changeset 755 for trunk


Ignore:
Timestamp:
02/21/07 04:26:10 (13 years ago)
Author:
ray
Message:
  • Ticket #963 DOMwalk IE: head tag attributes without quotes and closing slash
  • Ticket #962 DOMwalk: Source looks better in IE than in Gecko
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/GetHtml/DOMwalk.js

    r742 r755  
    5353 
    5454Xinha.emptyAttributes = " checked disabled ismap readonly nowrap compact declare selected defer multiple noresize noshade "; 
     55Xinha.elGetsNewLine = function (el) { return (" br meta link title ".indexOf(" " + el.tagName.toLowerCase() + " ") != -1);}; 
    5556 
    5657Xinha.getHTMLWrapper = function(root, outputRoot, editor, indent) 
     
    114115          html += (Xinha.is_ie ? ('\n' + indent) : '') + "<head>"; 
    115116        } 
    116         // lowercasize 
     117         
    117118        var save_multiline = RegExp.multiline; 
    118119        RegExp.multiline = true; 
    119         var txt = root.innerHTML.replace(Xinha.RE_tagName, function(str, p1, p2) { return p1 + p2.toLowerCase(); }); 
     120        var txt =  
     121        root.innerHTML.replace(Xinha.RE_tagName, function(str, p1, p2) { return p1 + p2.toLowerCase(); }) // lowercasize 
     122        .replace(/\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g, '="$2$4$5"$3') //add attribute quotes 
     123        .replace(/<(link|meta)((\s*\S*="[^"]*")*)>/g, '<$1$2 />'); //terminate singlet tags 
    120124        RegExp.multiline = save_multiline; 
    121125        html += txt + '\n'; 
     
    129133      { 
    130134        closed = (!(root.hasChildNodes() || Xinha.needsClosingTag(root))); 
    131         html += (Xinha.is_ie && Xinha.isBlockElement(root) ? ('\n' + indent) : '') + "<" + root.tagName.toLowerCase(); 
     135        html += ((Xinha.isBlockElement(root) || Xinha.elGetsNewLine(root)) ? ('\n' + indent) : '') + "<" + root.tagName.toLowerCase(); 
    132136        var attrs = root.attributes; 
    133137         
     
    280284        if ( outputRoot && !closed ) 
    281285        { 
    282           html += (Xinha.is_ie && Xinha.isBlockElement(root) && containsBlock ? ('\n' + indent) : '') + "</" + root.tagName.toLowerCase() + ">"; 
     286          html += (((Xinha.isBlockElement(root) && containsBlock) || root_tag == 'head' || root_tag == 'html') ? ('\n' + indent) : '') + "</" + root.tagName.toLowerCase() + ">"; 
    283287        } 
    284288      } 
     
    286290 
    287291    case 3: // Node.TEXT_NODE 
    288       html = /^script|noscript|style$/i.test(root.parentNode.tagName) ? root.data : Xinha.htmlEncode(root.data); 
     292      html = /^script|noscript|style$/i.test(root.parentNode.tagName) ? root.data : Xinha.htmlEncode(root.data).trim(); 
    289293    break; 
    290294 
Note: See TracChangeset for help on using the changeset viewer.