Permalink
Browse files

use stable attribute sorting

  • Loading branch information...
1 parent f05d047 commit b617985d9ace0745a6b2baa825a66476c3aa86bb @minad minad committed Sep 7, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/temple/html/attribute_sorter.rb
@@ -10,9 +10,10 @@ def call(exp)
end
def on_html_attrs(*attrs)
+ n = 0 # Use n to make sort stable. This is important because the merger could be executed afterwards.
[:html, :attrs, *attrs.sort_by do |attr|
raise(InvalidExpression, 'Attribute is not a html attr') if attr[0] != :html || attr[1] != :attr
- attr[2].to_s
+ [attr[2].to_s, n += 1]
end]
end
end

0 comments on commit b617985

Please sign in to comment.