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

Add support for standard-compliant placeholder option #617

Merged
merged 2 commits into from
Oct 22, 2019

Conversation

stof
Copy link
Contributor

@stof stof commented Jul 18, 2019

Description

Fixes #447

Replaces #474. The implementation is almost the same. But my PR preserves backward compatibility by using <option placeholder> as a fallback when there is no <option value="">.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@jshjohnson jshjohnson left a comment

Choose a reason for hiding this comment

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

Would you mind incrementing a minor version please? Thanks!

return (
this.element.querySelector('option[value=""]') ||
this.element.querySelector('option[placeholder]')
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind just adding a comment here explaining why both are supported please 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jshjohnson done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you also mind incrementing a minor version please (not major - ignore my original comment )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done (as a separate commit, as updating the build file for the new version also included other changes which were not yet in it).

Copy link
Contributor

Choose a reason for hiding this comment

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

@jshjohnson @stof That should be done in the same .querySelector('option[value=""], option[placeholder]')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tinovyatkin no, that's not the same. Your proposal would use whatever is found first. My code is using the standard way if it is there (and so if you define both, the standard way wins)

Copy link
Contributor

Choose a reason for hiding this comment

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

@jshjohnson
Ugh, if somebody defines both, one with invalid, but very implicit and documented (by this library) attribute placeholder and second one just with empty value and empty value starts winning - I think it's a breaking change.

@jshjohnson jshjohnson merged commit 8782564 into Choices-js:master Oct 22, 2019
@stof stof deleted the standard_placeholder branch October 22, 2019 10:55
jshjohnson pushed a commit that referenced this pull request Oct 22, 2019
* Add support for standard-compliant placeholder option

* Bump version and rebuild files
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.

placeholder attribute on option is invalid
3 participants