-
Notifications
You must be signed in to change notification settings - Fork 643
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
Conversation
…up from a negative number
@@ -40,7 +40,7 @@ function joiner(sep) { | |||
function globals() { | |||
return { | |||
range: function(start, stop, step) { | |||
if(!stop) { | |||
if(!stop && stop !== 0) { |
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.
Could we do if(typeof stop === 'undefined')
here instead? Seems to communicate the actual intent more clearly.
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 about the null
/ false
cases?
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.
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
.
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.
Sure thing, I'll add the requested change then. My main concern was breaking backwards compatibility as little as possible.
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.
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.
Thanks! Yes, new browser builds always happen at release time. |
…g null, empty string, false as second value)
fix range template global to work with zero stop-value
fix range template global to work with zero stop-value
Thanks for the quick turnaround, I appreciate your work here! |
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)