Skip to content

Fix bug: directive sort is not stable on Chrome #3149

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

Merged
merged 1 commit into from
Jun 28, 2016
Merged

Conversation

furybean
Copy link

I'm building a tabs component. It is used like this:

<tabs>
  <tab title="1">Tab1</tab>
  <tab title="2">Tab2</tab>
  <tab title="3">Tab3</tab>
  <tab title="4">Tab4</tab>
  <tab title="5">Tab5</tab>
  <tab title="6">Tab6</tab>
  <tab title="7">Tab7</tab>
  <tab title="8">Tab8</tab>
  <tab title="9">Tab9</tab>
  <tab title="10">Tab10</tab>
</tabs>

Live demo(Works fine)

It works fine when there are less than 10 <tab>s. But tabs will disorder when I have more than 10 <tab>s.

Live demo(Bug)

The main reason is that the directive sorting by priority is not stable on Chrome.

I fixed this bug using a sort method(time: O(n), space: O(n)), It also can be fixed using a stable sort method such as merge sort.

@yyx990803
Copy link
Member

多谢,我发布 1.0.26 的时候忘记先 merge 这个了...

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.

2 participants