I've found a bug while using replaceHTML kss command.
The deal here is to create a DIV element to let the browser engine to parse
HTML code. The problem is that in gecko browser (maybe others too) when
adding a node requiring a special parent node (LI, TR, TD, DT, DD etc...) it
will skip those nodes because the DIV  element does not fit in this case.

Here's my dirty quick patch:

var restrictedParentNodes = {
    'th': 'thead',
    'td': 'tr',
    'tr': 'table',
    'thead': 'table',
    'tbody': 'table',
    'tfoot': 'table',
    'li': 'ul',
    'dt': 'dl',
    'dd': 'dl',
    'option': 'select',
    'optgroup': 'select',
};
kukit.dom.parseHTMLNodes = function(txt){
    var firstNode = /<([^> ]*)[> ]/.exec(txt);
    firstNode = firstNode ? firstNode[1] : null;
    var node = document.createElement(restrictedParentNodes[firstNode] ||
'div');
    node.innerHTML = txt;
     console.log(node.firstChild);
    // gecko engine automatically adds a TBODY node
    if (node.firstChild) {
        if (node.firstChild.nodeType == 3)
            node.removeChild(node.firstChild);
        if (node.firstChild.nodeName == 'TBODY')
            node = node.firstChild;
    }
    var resultNodes = [];
    for (var i=0; i<node.childNodes.length; i++) {
        resultNodes.push(node.childNodes.item(i));
    }
    return resultNodes;
};
-- 
Christophe BOSSE - Développeur
INGENIWEB (TM) - SAS 50000 Euros - RC B 438 725 632
Bureaux de la Colline - 1 rue Royal - Bâtiment D - 9ème étage
92210 Saint Cloud - France
Phone : 01 78 15 24 02 / Fax : 01 46 02 44 04
http://www.ingeniweb.com - une société du groupe Alter Way
_______________________________________________
Kss-devel mailing list
Kss-devel@codespeak.net
http://codespeak.net/mailman/listinfo/kss-devel

Reply via email to