|
From: <dg...@mo...> - 2004-11-24 12:15:21
|
Hello,
for a web application I build a dom-tree in memory and depending on
user input I hide or display certain parts of the dom-tree.
Sample session to create the document:
(tclkit) 2 % package require xml::tcl
3.0
(tclkit) 3 % set doc [dom::DOMImplementation create]
invalid command name "dom::DOMImplementation"
(tclkit) 4 % package require dom
3.0
(tclkit) 5 % set doc [dom::DOMImplementation create]
::dom::tcl::document1::Document
(tclkit) 6 % set top [dom::document createElement $doc html]
::dom::tcl::document1::node2
(tclkit) 7 % set head [dom::document createElement $top head]
::dom::tcl::document1::node6
(tclkit) 8 % set title [dom::document createElement $head title]
::dom::tcl::document1::node10
(tclkit) 9 % set titleText [dom::document createTextNode $title "MPIMG Berlin - Mouse Database"]
::dom::tcl::document1::node14
(tclkit) 10 % set body [dom::document createElement $top body]
::dom::tcl::document1::node18
(tclkit) 11 % set div [dom::document createElement $body div]
::dom::tcl::document1::node22
(tclkit) 12 % dom::element setAttribute $div style display:none;
display:none
(tclkit) 13 % set div [dom::document createElement $body div]
::dom::tcl::document1::node27
(tclkit) 14 % [dom::document createTextNode $div Test]
wrong # args: should be "::dom::tcl::document1::node31 method args"
(tclkit) 15 % dom::document createTextNode $div Test
::dom::tcl::document1::node35
(tclkit) 16 % $doc serialize -html
unknown method "serialize"
(tclkit) 17 % dom::serialize $doc -method "html"
<?xml version='1.0'?>
<!DOCTYPE html>
<html><head><title>MPIMG Berlin - Mouse Database</title></head><body><div style="display:none"/><div>TestTest</div></body></html>
(tclkit) 18 % dom::serialize $doc -method "html" -indent
list must have an even number of elements
(tclkit) 19 % dom::serialize $doc -method "html" -indent 2
<?xml version='1.0'?>
<!DOCTYPE html>
<html>
<head>
<title>MPIMG Berlin - Mouse Database</title>
</head>
<body>
<div style="display:none"/>
<div>TestTest</div>
</body>
</html>
both outputs did not render the text although the TestTest-text is not
a parent of the display:none-div.
if we change the html-code manually to
<html>
<head>
<title>MPIMG Berlin - Mouse Database</title>
</head>
<body>
<div style="display:none"></div>
<div>TestTest</div>
</body>
</html>
which should be the same than it renders right. So my adivise is to
change the following:
$ diff /d/tcl-lib/tcldom3.0/dom.tcl ~/cvs/tclhttpd/customlib/tcldom3.0/dom.tcl
... some other stuff
<
< append result />$newline
---
> # dgroth fixes bad browser behaviour with <div style='display:none'/> tags
> append result "></$nsPrefix$node(node:localName)>$newline"
Or at least allow a option with serialize like:
::dom::DOMImplementation serialize $doc -emptytags false
I think with tdom this is the default because I did not observe this
missbehaviour (of modern browsers) until now.
regards,
Detlef
--
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235
|