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

fix range template global to work with zero stop-value #638

Merged
merged 2 commits into from
Jan 19, 2016

Conversation

devoidfury
Copy link
Contributor

I'm using range to iterate up from a dynamic range, which is negative sometimes. This patch fixes the case that the stop-value is exactly zero. Added test case.

(This will also need a fresh browser build, not included)

@@ -40,7 +40,7 @@ function joiner(sep) {
function globals() {
return {
range: function(start, stop, step) {
if(!stop) {
if(!stop && stop !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do if(typeof stop === 'undefined') here instead? Seems to communicate the actual intent more clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the null / false cases?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range isn't documented as accepting null or false for these arguments, and there's no reason to pass them. The purpose of this clause is just to handle the case where only one or two arguments are provided, and in that case the not-provided arguments are undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I'll add the requested change then. My main concern was breaking backwards compatibility as little as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I appreciate the motivation to preserve maximum back-compat. But back-compat for undocumented edge-cases always has to be weighed against the likelihood of someone actually relying on the current behavior (for reasonable reasons), and I just don't see it here.

@carljm
Copy link
Contributor

carljm commented Jan 19, 2016

Thanks! Yes, new browser builds always happen at release time.

…g null, empty string, false as second value)
carljm added a commit that referenced this pull request Jan 19, 2016
fix range template global to work with zero stop-value
@carljm carljm merged commit 8984d58 into mozilla:master Jan 19, 2016
carljm added a commit that referenced this pull request Jan 19, 2016
fix range template global to work with zero stop-value
@devoidfury
Copy link
Contributor Author

Thanks for the quick turnaround, I appreciate your work here!

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