Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the feature for "instanceof" checking #652

Open
finscn opened this issue Oct 13, 2016 · 1 comment
Open

the feature for "instanceof" checking #652

finscn opened this issue Oct 13, 2016 · 1 comment

Comments

@finscn
Copy link
Contributor

finscn commented Oct 13, 2016

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 ~~
finscn@5f80a03

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
Copy link
Contributor Author

finscn commented Oct 14, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant