-
Notifications
You must be signed in to change notification settings - Fork 25
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
Kept order of headers #32
Conversation
Hmmm, this would mean a major API break. |
Or save the order of headers to the new property for serialization. |
Could you elaborate a bit on that? |
The new instance property of type |
So the existing That sounds like a better (backwards-compatible) solution. Should make the change much smaller as well. |
The problem is how to sort the default headers. Are the default headers necessary? |
08486e3
to
c7a6038
Compare
@rubenv, |
lib/po.js
Outdated
'Content-Type': '', | ||
'Content-Transfer-Encoding': '', | ||
'Plural-Forms': '', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep this? I know it's ugly, but (if I remember correctly) some tools balk when these are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept.
lib/po.js
Outdated
var self = this; | ||
keys.forEach(function (key) { | ||
this.headerOrder.forEach(function (key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I manually do po.headers["test"] = "123"
.
Not sure if that will still get serialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Great, thanks for the fixes! Really like it now, as it's now a non-breaking change. I see no reason not to include this. Can we come up with a unit test that fails without this in place (but obviously works with)? That way we'll be assured that we won't break it in the future. Such a test might depend on the enumeration order in JS (not 100% sure how that works), so might be hard to write. Don't worry if that's the case, we'll just merge without one then. |
@rubenv, some unit test added. |
Perfect! Excellent work. Merged! |
Also pushed to NPM as |
@rubenv, thank you too. |
When the
pofile
loads and saves the PO file saved by another application, headers will be swapped. This then causes frequent differences in commits when PO file is indexed bygit
. A possible solution would be to change an object containing headers to an array.