-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
class-attribute is reordered when using .foo and (class="foo") #306
Comments
I'm tentatively okay with this, but it's important that the classes are emitted in a deterministic order for testing purposes. Internally, Haml does |
|
For anyone else hitting this problem and needing a quick solution, I have hacked together some quick code (based on #882) that you can require to fix this. # Override Haml to NOT sort class attributes.
#
# This is required because Semantic/Fomantic care about class ordering :facepalm:
#
# @see https://github.com/haml/haml/issues/306
module Haml
module AttributeBuilder
class << self
alias_method :original_merge_value, :merge_value
def merge_value(key, to, from)
if key == 'class'
merged_class = filter_and_join(from, ' ')
if to && merged_class
merged_class = (to.split(' ') | merged_class.split(' ')).join(' ')
elsif to || merged_class
merged_class ||= to
end
merged_class
else
original_merge_value(key, to, from)
end
end
end
end
end I have not seen any problems yet, but please let me know if you find anything! |
Coming into alignment with the haml-spec and based off of the decision made at haml/haml-spec#15 and #306
This has been implemented. |
I was confused by this output when I tried to use jquery-tmpl conditions in the class:
The current behavior prevents duplicate classes (
.foo(class="foo")
) but it would be better just to leave the class-attribute order untouched.The text was updated successfully, but these errors were encountered: