Skip to content

Commit

Permalink
Merge c646f5d into 6a9c193
Browse files Browse the repository at this point in the history
  • Loading branch information
Usame Algan committed Apr 2, 2020
2 parents 6a9c193 + c646f5d commit 22f051b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ JavaScript disabled? No problem! Nicely degrades to original `<select>`.
| Option | Required | Description |
| ------ | -------- | ------------------------------------------------------------------ |
| elem | yes | _id_ of the select you want to replace **or** a direct DOM element |
| bubbles | no | Boolean indicating whether the change event of the select bubbles |

## Methods

Expand Down
2 changes: 1 addition & 1 deletion dist/vanilla-js-dropdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/javascript/vanilla-js-dropdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/javascript/vanilla-js-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @param {(string|Object)} options.elem - HTML id of the select or the DOM element.
*/
var CustomSelect = function(options) {
var elem =
typeof options.elem === 'string' ? document.getElementById(options.elem) : options.elem,
var elem = typeof options.elem === 'string' ? document.getElementById(options.elem) : options.elem;
var bubbles = typeof options.bubbles === 'boolean' ? true : false,
mainClass = 'js-Dropdown',
titleClass = 'js-Dropdown-title',
listClass = 'js-Dropdown-list',
Expand Down Expand Up @@ -117,7 +117,7 @@ var CustomSelect = function(options) {
elem.options.selectedIndex = t.getAttribute('data-index');

//trigger 'change' event
var evt = new CustomEvent('change');
var evt = bubbles ? new CustomEvent('change', {bubbles: true}) : new CustomEvent('change');
elem.dispatchEvent(evt);

// highlight the selected
Expand Down

0 comments on commit 22f051b

Please sign in to comment.