LivePage cannot append rows to tables?
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. Thanks muchly, Mike.
On Mon, 21 Nov 2005 17:14:43 -0500, Mike Pelletier <mike@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. Jean-Paul
On Mon November 21 2005 18:12, Jean-Paul Calderone wrote:
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.
That is what I am seeing, yep.
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.
Thanks a lot for the hints. I think you are suggesting something like: function nevow_appendNode(node, what) { var oldnode = document.getElementById(node); oldnode.innerHTML += what; } This works just dandy on Firefox, and not at all on IE. I get, "Error: unknown runtime error." But oh well, it's a start. Probably I'll look into hacking nevow_glue.js to use MochiKit.DOM. Or...
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.
...should I be looking into this? I wasn't aware of nevow.athena, but I see I've got it installed. I don't have any legacy code to worry about, should I just skip nevow.livepage completely? Would you trust 0.6.0 not to put its elbows on the table or vomit on the Japanese? I don't really want to hack up javascript if I can avoid it. Mike.
On Mon, 21 Nov 2005 20:44:55 -0500, Mike Pelletier <mike@mkp.ca> wrote:
On Mon November 21 2005 18:12, Jean-Paul Calderone wrote:
[snip - athena]
...should I be looking into this? I wasn't aware of nevow.athena, but I see I've got it installed. I don't have any legacy code to worry about, should I just skip nevow.livepage completely? Would you trust 0.6.0 not to put its elbows on the table or vomit on the Japanese? I don't really want to hack up javascript if I can avoid it.
It works alright in 0.6 (there might be some puking, but it is relatively limited in scope - bathroom only, I would say). It works better in current trunk@HEAD. The API isn't stable yet (it has changed between 0.6 and trunk@HEAD, it will change some more, I think), and there's definitely a few things to fix before I'd say it's deployable. I'd recommend at least taking a look at it: writing larger apps will definitely be easier with it than with nevow.livepage. On the other hand, if you only have a few "live" requirements, since you already have some nevow.livepage code, you might want to stick with that for now. It won't be disappearing suddenly for several releases at least ;) Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
Mike Pelletier