Christophe Bosse wrote:
> 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
Thanks for the report !
I think your fix looks nice !
--
Godefroid Chapelle (aka __gotcha) http://bubblenet.be
_______________________________________________
Kss-devel mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kss-devel