Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

the feature for "instanceof" checking

Open finscn opened this issue 9 years ago • 1 comments

Hi , @phoboslab ,

In Ejecjta , the below "instanceof" checking can't pass :

img instanceof HTMLImageElement 
canvas instanceof HTMLCanvasElement
video instanceof HTMLVideoElement
audio instanceof HTMLAudioElement

In PIXI.js v4 , the "instanceof" checking is very useful , I hope Ejecta could support it.

~~I add this feature in my fork version ~~ ~~https://github.com/finscn/Ejecta/commit/5f80a03747233efba914a2793bf4db10c9159d80~~

I hope it could help you.

There are too many differences between my fork version and origin ejecta , So I don't give a PR. And I found that you have never accept my PR , maybe there are too many differences between our code spec. & style , So I think my PR is useless for you.

finscn avatar Oct 13 '16 16:10 finscn

I found an easy way to implement this feature , just add this code to Ejecta.js

(function(){

    var element = document.createElement("img");
    HTMLImageElement = function(){};
    HTMLImageElement.prototype = element.__proto__;

    var element = document.createElement("canvas");
    HTMLCanvasElement = function(){};
    HTMLCanvasElement.prototype = element.__proto__;

    var element = document.createElement("video");
    HTMLVideoElement = function(){};
    HTMLVideoElement.prototype = element.__proto__;

    var element = document.createElement("audio");
    HTMLAudioElement = function(){};
    HTMLAudioElement.prototype = element.__proto__;

})();

Notice : the code must be after "window.document = { ... }" in Ejecta.js.

finscn avatar Oct 14 '16 21:10 finscn