Skip to content

Conversation

ThisUsedToBeAnEmail
Copy link

No description provided.

Copy link
Member

@preaction preaction left a comment

Choose a reason for hiding this comment

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

This all looks great, thanks! I added some comments on some things that I think would make it cleaner, but they're not requirements.

Is this ready to merge otherwise? Or is that where #34 comes in?

});

input.addEventListener('keyup', function () {
input.value = input.value.replace(new RegExp("([^a-zA-Z0-9\-]+)", "g"), "");
Copy link
Member

Choose a reason for hiding this comment

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

You can do this without JavaScript if you'd like by using the <input pattern="..." /> HTML attribute (MDN docs). If the input doesn't pass validation, the submit event shouldn't(?) happen.

Copy link
Author

Choose a reason for hiding this comment

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

It's just a preference, I prefer validating the input and preventing the characters this way.

}
};

let dists = [
Copy link
Member

Choose a reason for hiding this comment

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

This might be better as let dists = <%= encode_json $dists %>, but that's just an opinion, not a requirement :)

setupEvents: function () {
let self = this;
let input = self.search_form.querySelector('input#search');
self.search_form.addEventListener('submit', function (evt) {
Copy link
Member

Choose a reason for hiding this comment

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

If you use arrow functions, you can get rid of the need to do let self = this;:

this.search_form.addEventListener('submit', (evt) => {
   // inside here, `this` is the same as outside
});

@ThisUsedToBeAnEmail
Copy link
Author

Yes you can merge this without merging #34 as 34 is just a fork of this with the main changes being on the /dist/ pages.

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