-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug using attr function in a SVG.Text element #13
Comments
In which scenario can draw.text() But that is bad practice because the first argument is required. It would be like ordering a glass of water but asking the waiter to leave the glass empty. If one would like to create an empty text element, this is the proper way to do it: draw.text('') |
That's true, I wasn't using the api provided in the documentation, but my scenario is this: I fetch objects from the server in json format, like
so in order to create a new object, I do the next
|
Ok, I see where you're getting at. In this case it might be better do a little bit more coding: var element = obj.type == 'rect' || obj.type == 'ellipse' ?
draw[obj.type](0,0) :
obj.type == 'image' || obj.type == 'text' ?
draw[obj.type]('') :
obj.type == 'line' ?
draw.line(0,0,0,0) :
obj.type == 'g' ?
draw.group() :
draw[obj.type]()
element.attr(obj.attrs) |
An additional thought, it is always safer to work with the official api because it is much less likely to change. |
In SVG.Element.attr function this.lines can be undefined, because in SVG.Text constructor you dont set this.lines = []
(excuse my bad english)
The text was updated successfully, but these errors were encountered: