Skip to content

Commit

Permalink
Fix inline events not working on firefox
Browse files Browse the repository at this point in the history
onloadedmetadata doesn't work on Firefox. I am guessing,
this is because it only applies on <video> tags. I used,
auxclick which works on all browsers instead. Since, the
event doesn't bubble, it shouldn't create any issue.
  • Loading branch information
shubhamjain committed Jun 24, 2022
1 parent f26142c commit cb882dd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions svg-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ const renderBody = (elem, options, body) => {
// Here we are recycling a rarely used GlobalEventHandler 'onloadedmetadata'
// and offloading the execution to the browser. This is a hack, but because
// the event doesn't bubble, it shouldn't affect anything else in the code.
elem.setAttribute('onloadedmetadata', elem.getAttribute('oniconload'));
elem.setAttribute('onauxclick', elem.getAttribute('oniconload'));

const event = new CustomEvent('loadedmetadata', {
bubbles: false
const event = new CustomEvent('auxclick', {
bubbles: false,
view: window
});
elem.dispatchEvent(event);

elem.removeAttribute('onloadedmetadata');
elem.removeAttribute('onauxclick');
}
};

Expand Down

0 comments on commit cb882dd

Please sign in to comment.