4xx / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
0 stars 0 forks source link

TypeError: label.prop is not a function #1135

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. In the main menu, select "Image library" -> "Demo library" -> "smiley.svg"

2. Check web browser error console - in Firefox (using Firebug) it will say: 
"TypeError: label.prop is not a function".  In IE 10 it will say: "TypeError: 
Object doesn't support property or method 'prop'".  In Chrome it will just say 
"TypeError".

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

Presumably the label for this object ("Cool smiley") is supposed to be 
disabled, but it is not, due to the exception being thrown.

In what browser did you experience this problem? (ALL, Firefox, Opera, etc)

All browsers (error message varies by browser).

In what version of SVG-edit does the problem occur? (Latest trunk, 2.5.1,
etc)

Latest trunk (r2524).

Please provide any additional information below.

In line 1635 of svg-editor.js:

  label.prop('disabled', el_name == 'use');

Note that label is a DOM element, not a jQuery object.

http://code.google.com/p/svg-edit/source/browse/trunk/editor/svg-editor.js?r=251
6#1635

Original issue reported on code.google.com by e...@siliconforks.com on 1 Sep 2013 at 8:48

GoogleCodeExporter commented 9 years ago
Looks like this happens whenever you try to create/interact with a group <g>. 
Is the fix as easy as making sure label is instead $(label) so that it's a 
jQuery object? It seems to work...

Questions I have:
1. What is the purpose of the label box? Is it even working as intended on 2.6?
2. The problem line above only disables the label box if the element type is 
"use" - when does an element type of "use" come into play here? I've only seen 
this error with groups, so the el_name is "g".

Original comment by dan...@trydesignlab.com on 6 Sep 2013 at 12:56

GoogleCodeExporter commented 9 years ago
For question #2 - the original steps to reproduce that I posted are actually an 
example of a case where the element is "use" (although as you noted, the error 
also occurs when working with "g" elements).

Original comment by e...@siliconforks.com on 6 Sep 2013 at 1:34

GoogleCodeExporter commented 9 years ago
Changing:
    var label = $('#g_title')[0]; 

To:
    var label = $('#g_title');

A few lines up fixes this for me...given that I'm not familiar with the label 
feature, it would be great if someone who is could chime in.

Original comment by dan...@trydesignlab.com on 6 Sep 2013 at 3:50

GoogleCodeExporter commented 9 years ago
Note that the next couple of lines expect a DOM element, though, instead of a 
jQuery object.

label.value = title;                       // expects DOM element
setInputWidth(label);                      // expects DOM element
label.prop('disabled', el_name == 'use');  // expects jQuery object

Original comment by e...@siliconforks.com on 6 Sep 2013 at 6:35

GoogleCodeExporter commented 9 years ago
Ah good point, so it's probably better to just change "label" to "$(label)" in 
the last line, to convert it to a jQuery object...

Original comment by dan...@trydesignlab.com on 6 Sep 2013 at 6:56

GoogleCodeExporter commented 9 years ago
On another note, I think this issue may be related to issue 1122.

Original comment by e...@siliconforks.com on 10 Sep 2013 at 10:44

GoogleCodeExporter commented 9 years ago
I went ahead and made an equivalent fix.

Original comment by bret...@gmail.com on 29 Oct 2013 at 4:47