How to properly extend HTMLImageElement

Viewed 373

Extending HTMLImageElement directly works okay for Chrome, Firefox etc.

export default class CustomImg extends HTMLImageElement {
    constructor() {
        super();
    }
}

However it does not work at Safari which says super() is an illegal constructor. According to MDN Image() is the proper constructor for HTMLImageElement (https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement). I tried to extend Image as well. However even though it does not print out any errors, it just does not behave as a CustomElement.

Any ideas on how to create a custom element on top of HTMLImageElement that can work for both Chrome and Safari?

1 Answers
Related