Skip to content
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

Sort HTML attributes by key #38

Merged
merged 1 commit into from Dec 19, 2014
Merged

Sort HTML attributes by key #38

merged 1 commit into from Dec 19, 2014

Conversation

bep
Copy link
Contributor

@bep bep commented Dec 18, 2014

HTML attributes are backed by a Go map, and since Go 1 the iteration order has been random.

This is not a problem for the browsers, but is a problem when using changed content as a way of detecting which files to deploy to a server.

This commit fixes that by ordering by attribute key.

Fixes #37

HTML attributes are backed by a Go map, and since Go 1 the iteration order has been random.

This is not a problem for the browsers, but is a problem when using changed content as a way of detecting which files to deploy to a server.

This commit fixes that by ordering by attribute key.

Fixes #37
@yosssi
Copy link
Owner

yosssi commented Dec 19, 2014

@bjornerik Thanks for your great work!

If possible, I'd like to change the type of htmlTag.attributes from the map of the strings to the slice of the custom attribute type which has the key and the value fields so that we could keep the order of the attributes on the template file and we could avoid the sort process which might lower the performance.

@bep
Copy link
Contributor Author

bep commented Dec 19, 2014

Sure - no problem, the fix I provided was the first I thought of. Performance is important!

yosssi added a commit that referenced this pull request Dec 19, 2014
@yosssi yosssi merged commit 72e9944 into yosssi:master Dec 19, 2014
@yosssi
Copy link
Owner

yosssi commented Dec 19, 2014

For now, I'll merge this PR. A PR which changes the type of htmlTag.attributes from the map to the slice is welcomed!

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.

Random ordering of HTML attributes
2 participants