[Twisted-web] LivePage cannot append rows to tables?

Jean-Paul Calderone exarkun at divmod.com
Mon Nov 21 16:12:41 MST 2005

On Mon, 21 Nov 2005 17:14:43 -0500, Mike Pelletier <mike at mkp.ca> wrote:
>I'm at my wit's end!  Have mercy on a clueless JS user and examine the
>attached page.
>The problem it illustates is one I am having with livepage.js's
>nevow_appendNode function.  I am finding that whenever I attempt to append a
>row to a table (or to a tbody, or for that matter to anything else) the HTML
>is silently stripped out and my node is added as a single #TEXT node.
>However, appending a DIV works fine, even when technically illegal; a DIV
>node containing the #TEXT is added.
>The attachment includes a copy'n'pasted version of nevow_appendNode.  The only
>modification I have made to it is to add an alert() which demonstrates the
>precise point of failure; assigning "what" to "newspan.innerHTML".  Note that
>the <div> tags are unmolested, but the <tr> and <td> tags are stripped.  I
>get the same behaviour from FF and IE, while Konq just barfs with a DOM
>exception 7.
>I simply don't know how to chase this one down any further.  I hope someone
>will tell me I'm a moron and point out what I've done wrong, but I think the
>solution is going to require a change to nevow_appendNode.

This fails because nevow_appendNode sets the HTML string as the innerHTML property of a DIV node.  The browser validates the resulting DOM, notices it is illegal (you cannot put a TR or a TD inside a DIV) and then either silently "fixes" it or reports an error.

This might be fixable by appending the given HTML string to the target node's innerHTML property.  I have tested it with Firefox and it seems to work in many cases there, but I have not tested it anywhere else.

I'm not terribly interested in trying to fix this (nor all the JS and HTML quoting issues) in LivePage.  Currently I'm focusing development effort on Athena which side-steps this whole class of problems.  However, if someone contributes a patch along with something to instill confidence that the change does not introduce a regression, it might get applied.


More information about the Twisted-web mailing list