Skip to content

Sort order of properties with the same index (#94)#130

Merged
mishanga merged 3 commits intodevfrom
tg/94-sort-order
Dec 17, 2013
Merged

Sort order of properties with the same index (#94)#130
mishanga merged 3 commits intodevfrom
tg/94-sort-order

Conversation

@tonyganch
Copy link
Copy Markdown
Member

Issue #94 + PR #104

The common problem appears to be with declarations that have same properties.
For example:

a {
    width: 0;
    width: 100%;
}

Array.prototype.sort gets confused about which declaration should appear first since they have the same group index and the same property index.
So I've decided to save node's index number as one of extended node's properties and then use it inside sorted.sort() as a helper.
It does the trick.

If two declarations have the same group index and the same property index, after
sorting they should stay in order of their original appearance.

Due to some strange behaviour of `Array.prototype.sort` properties get mixed
from time to time.
For example, this:

    a {
        width: 0;
        width: auto;
    }

can suddenly become this:

    a {
        width: auto;
        width: 0;
    }

In order to avoid such situations, save node index value within extended node
and take it into account while doing `sorted.sort()`.
@ghost ghost assigned mishanga Dec 14, 2013
@kizu
Copy link
Copy Markdown
Contributor

kizu commented Dec 16, 2013

Yay, this seems to fix issues I have, can't wait it to be merged! :)

mishanga added a commit that referenced this pull request Dec 17, 2013
Sort order of properties with the same index (#94)
@mishanga mishanga merged commit 903ee30 into dev Dec 17, 2013
@mishanga mishanga deleted the tg/94-sort-order branch December 17, 2013 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants