Gisellameloni / svg-edit

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

Unselect error in Chrome #1005

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Insert many grouped element from json
2. select one
3. right click -> ungroup
4. click on canvas

What is the expected output? What do you see instead?
Expected: selection disappeare. Deselected elements be reselectable.
Instead: selection doesn't disappeare, and I can't select this elements.

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

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

Please provide any additional information below.

The problem is Google Chrome has a unstable sort method. Please imlements merge 
sort.

My solution:
-use this: 
http://splatoperator.com/2011/10/add-stable-merge-sort-to-array-and-jquery-proto
types/
+patch:
Array.prototype.mergeSort = jQuery.fn.mergeSort = function mergeSort (compare) {

    var length = this.length,
    middle = Math.floor(length / 2);

    // First selected node isn't array
    if (typeof length == "undefined" || length < 2)
        return this;

    if (!compare) {
        compare = function(left, right) {
            if (left < right) 
                return -1;
            if (left == right)
                return 0;
            else
                return 1;
        };
    }

    return merge(
        this.slice(0, middle).mergeSort(compare),
        this.slice(middle, length).mergeSort(compare),
        compare
    );
}
-and this at svgcanvas.js@2200:
selectedElements.mergeSort(function(a,b) {
        if(a && b && a.compareDocumentPosition) {
            return 3 - (b.compareDocumentPosition(a) & 6);  
        } else if(a == null) {
            return 1;
        }
    });   

Original issue reported on code.google.com by hajdua...@gmail.com on 31 Aug 2012 at 7:55

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Please review this patch, it can be usable quicksort.

Original comment by hajdua...@gmail.com on 1 Sep 2012 at 9:09

Attachments: