javascript - How to prevent IE10 from crashing when it tries to use the DomObject.filters property? -


i have old javascript code can't change crashing on ie10 (i can change other script files).

here crashing code:

if(isinternetexplorer && this.domelement.filters[0])   this.domelement.filters[0].play() 

that code not crash in ie8/9 because dom element has non standard property "filters".

here documentation filters property.

the solution can think of change htmlelement's prototype don't feel possible or thing do.

so how can prevent ie10 crashing when tries use domobject.filters property?

[edit] found 'solution'. @jam's solution.:

if (!htmldivelement.filters) {     htmldivelement.prototype.filters = []; } 

but still feel bad modifying browser native object's prototype.

as said, overriding prototype of object 1 way of doing it; so if there no other alternative try this:

object.prototype.filters = object.prototype.filters || []

or better (as suggested self):

htmldivelement.prototype.filters = htmldivelement.prototype.filters || []

this set filters property of object, if non-existing.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -