sgzwiz / brython

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

DOMObject missing some API and/or possible side effects of print() #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Console / Brython version 1.0.20130109-230634 / FF 17.0.1

The following code fails:

x = doc.createElementNS("http://www.w3.org/1999/svg", "image")
x.setAttributeNS('http://www.w3.org/1999/xlink',"xlink:href", "value")
x.setAttribute("x", "0")

with:

ExecutionError: x.__getattr__ is not a function
module '__main__' line 2
x.setAttributeNS('http://www.w3.org/1999/xlink',"xlink:href", "value") @ 
http://www.brython.info/py_utils.js:139

but adding a print(x) before using the setter works:

x = doc.createElementNS("http://www.w3.org/1999/svg", "image")
print(x)
x.setAttributeNS('http://www.w3.org/1999/xlink',"xlink:href", "value")
x.setAttribute("x", "0")

Original issue reported on code.google.com by pedro.ro...@gmail.com on 10 Jan 2013 at 10:06

GoogleCodeExporter commented 9 years ago
In this case you should use the built-in function JSObject to be able to use 
the variable :

x = JSObject(doc.createElementNS("http://www.w3.org/1999/svg", "image"))
x.setAttributeNS('http://www.w3.org/1999/xlink',"xlink:href", "value")
x.setAttribute("x", "55")
print(x.getAttribute("x"))

Original comment by pierre.q...@gmail.com on 23 Feb 2013 at 6:56