4xx / svg-edit

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

Mouse up event may cause error #1177

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
All I reported are about svg-edit 2.6.

In mouseUp event handler, evt.target may not have good parentNode and causes 
error.

I placed a <use> object references an image in defs. Then enter line-drawing 
mode. Move mouse cursor over <use> object and simply clicking will cause 
javascript error. In the case, evt.target is not a just <use> element. so 
parentNode cannot be referenced.

        if (!keep && element != null) {
            // ここでエラーが発生することがある
            // evt.targetが適切でない場合がある
            try {
                getCurrentDrawing().releaseId(getId());
                element.parentNode.removeChild(element);
                element = null;

                var t = evt.target;

                // if this element is in a group, go up until we reach the top-level group 
                // just below the layer groups
                // TODO: once we implement links, we also would have to check for <a> elements
                while (t.parentNode.parentNode.tagName == "g") {
                    t = t.parentNode;
                }
                // if we are not in the middle of creating a path, and we've clicked on some shape, 
                // then go to Select mode.
                // WebKit returns <div> when the canvas is clicked, Firefox/Opera return <svg>
                if ( (current_mode != "path" || !drawn_path) &&
                    t.parentNode.id != "selectorParentGroup" &&
                    t.id != "svgcanvas" && t.id != "svgroot") 
                {
                    // switch into "select" mode if we've clicked on an element
                    canvas.setMode("select");
                    selectOnly([t], true);
                }
            }
            catch (e) {
                //debugTrace("" + e);
            }

        } else if (element != null) {

Original issue reported on code.google.com by psh....@gmail.com on 25 Jan 2014 at 6:48