Skip to content

Commit

Permalink
IE support for events dispatching
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanda committed Mar 7, 2016
1 parent 9e8126b commit 5ed8959
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
14 changes: 10 additions & 4 deletions dist/happy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Happy = (function() {
};

Happy.prototype.checkCheckboxStateOnClick = function(e) {
var event, happy_input, input, selector;
var event, happy_input, ie, input, selector;
if (e.target.tagName === 'svg') {
happy_input = e.target.parentNode;
} else if (e.target.tagName === 'rect') {
Expand All @@ -157,9 +157,15 @@ Happy = (function() {
input.checked = true;
happy_input.classList.add('active');
}
event = new Event('change', {
'bubbles': true
});
ie = window.navigator.userAgent.indexOf("MSIE ");
if (ie) {
event = document.createEvent('Event');
event.initEvent('change', true, true);
} else {
event = new Event('change', {
'bubbles': true
});
}
return input.dispatchEvent(event);
}
};
Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var PATHS = {
styles : 'src/sass/happy.scss',
styles_all : 'src/sass/**/*.scss',
scripts : 'src/coffee/**/*.coffee',
styles_compiled : 'dist/css',
scripts_compiled : 'dist/js'
styles_compiled : 'dist',
scripts_compiled : 'dist'
};


Expand Down
11 changes: 9 additions & 2 deletions src/coffee/happy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,15 @@ class Happy
input.checked = true
happy_input.classList.add('active')

event = new Event('change', {'bubbles': true})
input.dispatchEvent(event)
ie = window.navigator.userAgent.indexOf("MSIE ")

if ie
event = document.createEvent('Event')
event.initEvent('change', true, true);
else
event = new Event('change', {'bubbles': true})

input.dispatchEvent(event);

checkCheckboxStateOnChange: (e) =>
if e.target.classList.contains('happy')
Expand Down

0 comments on commit 5ed8959

Please sign in to comment.