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

suggested fix for #124 #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kyzrfranz
Copy link

@kyzrfranz kyzrfranz commented Dec 16, 2016

Hey Ben, stumbled across this fr and thought what the hell - any remarks, would be happy to help some more?

#124

@@ -652,7 +669,27 @@
},
_withinValidRange: function(date) {
if (this._isValidDate(date)) {
return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove double space

@@ -289,6 +289,22 @@
value: null
},
/**
*Array of selectable dates
* (whitelist)
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add Format must be String YYYY-MM-DD here as well as on invalidDates so it's documented for people using this element stand-alone.

return false;
},

_confirmsToWhiteAndBlacklist: function(date){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Collapse these 3 into:

/**
 * Ensures that our date is valid and passes both white and black list checks.
 * @protected
 *
 * @param {Date} date
 * @return {Boolean}
 */
_checkWhiteBlackLists: function(date) {
  return this._isValidDate(date) &&
    (this.validDates || []).indexOf(this.dateFormat(date,'YYYY-MM-DD')) < 0 &&
    (this.invalidDates || []).indexOf(this.dateFormat(date,'YYYY-MM-DD')) < 0;
}

So we aren't biting the cost of always checking both lists, and checking for a valid date 3 times when we don't have to.

@admwx7
Copy link
Collaborator

admwx7 commented Sep 18, 2017

BTW, this doesn't actually address #124 since this is adding white/black list support, #124 is actually a request to be able to select a range of dates (start through end) in a single date-picker so we'll need another PR in order to resolve the issue completely, thanks for the PR though!

@admwx7
Copy link
Collaborator

admwx7 commented Sep 18, 2017

Fixes #113

@kyzrfranz
Copy link
Author

You're completely right, will change tonight.
Thanks for the remarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants