[Seaside] [FIX] liverUpdate JavaScript problem

Avi Bryant avi.bryant at gmail.com
Fri Jan 7 23:31:06 CET 2005


On Fri, 7 Jan 2005 17:11:09 -0500, James Megquier
<jmegq at post.harvard.edu> wrote:

> It matches too much for this case, for example:
> 
> "<html><body>
>    <span id=\"foo\">FOO
>      <span id=\"bar\">BAR</span>
>    </span>
>    <span id=\"oops\">OOPS</span>
> </body></html>"
> 
> I don't think it can be fixed, even with beefy modern regexes -- unless
> you build a parse tree so you can match up the end tags.

That's true, but not that big a deal - there wouldn't be any reason to
generate that kind of document on a liveUpate response.  The main
point of the regex is just to pull out the guts of the page from
whatever html/head/body etc stuff might be there.  It's assumed that
these guts will only include a single tag with id.

If we want to allow updating of multiple elements at once, as well as,
say, updating the attributes rather than the contents of an element,
we may want to change approaches and formalize an XML vocabulary for
updating the DOM.  So you would have something like:

<update-contents id="foo">
<![CDATA[
... new contents for "foo"...
]]>
</update-contents>

<update-attributes id="foo">
<attribute key="border">1</attribute>
<attribute key="bgcolor">red</attribute>
</update-attributes>

You might also want to throw in something like:

<evaluate-script>
<![CDATA[
document.getElementById.....
]]>
</evaluate-script>

for arbitrary changes.

Then we could get rid of the regex parser and actually use the XML
part of XmlHttpRequest.
We'd also have to come up with a good API on the Seaside end of things
to match; suggestions welcome.

Avi


More information about the Seaside mailing list