sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Regression: svg textContent does not affect printed text anymore #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Enter in brython web console:

import svg
svg_window = svg.svg(width="800", height="100")
svg_text = svg.text('old',x=350,y=45,
            font_size=20,text_anchor="middle",
            style={"stroke":"navy", 'fill':"navy"})
panel = doc['banner']
svg_window <= svg_text
panel<= svg_window
svg_text.textContent = "new, verbose and long text"
bbox = svg_text.getBBox()
w = JSObject(bbox).width
assert w >100, 'Changed text should be large, but is only %d wide'%w
print ('Ok')

What is the expected output? What do you see instead?

new, verbose and long text (printed in navy on the browser canvas)

Ok (printed on console)

instead I get:

old text (printed in navy on the browser canvas)

Console output:

AssertionError: Changed text should be large, but is only 26 wide
module '__main__' line 12
assert w >100, 'Changed text should be large, but is only %d wide'%w

What version of the product are you using? On what operating system?
Brython version 1.1.20130307-202952
Linux Mint 14

Please provide any additional information below.

was working up to Brython version 1.1.20130301-163146

Original issue reported on code.google.com by ca...@nce.ufrj.br on 8 Mar 2013 at 10:23

GoogleCodeExporter commented 9 years ago
Hi,
To set the text content, you should use

svg_text.text = "new, verbose and long text"

instead of textContent. I'm not sure why it worked in previous versions and not 
now, but with "text" your example seems to work - does it for you too ?

- Pierre

Original comment by pierre.q...@gmail.com on 9 Mar 2013 at 7:39

GoogleCodeExporter commented 9 years ago
The form element.text was not documented. I searched for the operation in 
javascript documentation and I found element.textContent as the official 
attribute and was working previously. It is ok if the fom element.text is 
adopted, but it must be clearly satated in the getting started documentation, 
otherwise users may get frustrated with textContent not working.

Original comment by ca...@nce.ufrj.br on 9 Mar 2013 at 5:03

GoogleCodeExporter commented 9 years ago
It is actually documented in the section "handling of HTML documents" of the 
documentation :

"the content of a DOM node can be read or modified by the text or html 
attributes, corresponding to innerText (or textContent) and innerHTML 
respectively, in Javascript"

- Pierre

Original comment by pierre.q...@gmail.com on 11 Mar 2013 at 8:25

GoogleCodeExporter commented 9 years ago

Original comment by pierre.q...@gmail.com on 17 Mar 2013 at 11:29