IE9 errors due to EcmaScript 5 incompatble getters/setters
Closed this issue · 11 comments
Errors appear in IE9:
SCRIPT438: Object doesn't support this property or method Box2dWeb-2.1a.2.js.js, line 2036 character 4
SCRIPT5007: 'undefined' is null or not an object Box2dWeb-2.1a.2.js.js, line 346 character 7
Only tested on Win 7 64bit - IE9 Beta 9.0.7930
Any ideas?
Original issue reported on code.google.com by smartm...@gmail.com
on 15 Jan 2011 at 12:41
I've got this to work in IE by changeing the __defineGetter__ and defineSetter
methods to Object.defineProperty
ie:
Object.defineProperty(
b2ContactID.prototype,
'key',
{
get:function(){
return this._key;
},
set:function(value){
if (value === undefined) value = 0;
this._key = value;
this.features._referenceEdge = this._key & 0x000000ff;
this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff;
this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff;
this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff;
}
}
);
/*
b2ContactID.prototype.__defineGetter__('key', function () {
return this._key;
});
b2ContactID.prototype.__defineSetter__('key', function (value) {
if (value === undefined) value = 0;
this._key = value;
this.features._referenceEdge = this._key & 0x000000ff;
this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff;
this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff;
this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff;
});*/
This will only work in ie9 and will throw errors in other browsers so I'm going
to do something like:
if (Modernizr.canvas){
if ($.browser.msie){
document.write(unescape('%3Cscript src="box2web-normal.js"%3E%3C/script%3E'))
} else {
document.write(unescape('%3Cscript src="box2web-ie9.js"%3E%3C/script%3E'))
}
}
Original comment by smartm...@gmail.com
on 16 Jan 2011 at 10:24
Attachments:
Sorry that if statement was the wrong way round:
if (Modernizr.canvas){
if ($.browser.msie){
document.write(unescape('%3Cscript src="box2web-ie9.js"%3E%3C/script%3E'))
} else {
document.write(unescape('%3Cscript src="box2web-normal.js"%3E%3C/script%3E'))
}
}
Original comment by smartm...@gmail.com
on 16 Jan 2011 at 10:25
Actually, IE isn't supported yet. But if this works, I'll add a wiki entry
about this workaround.
Original comment by Uli.He...@googlemail.com
on 17 Jan 2011 at 9:52
[deleted comment]
Sorry not an issue as such, just didn't know where to post it. Works really
well in IE9 with GPU support.
Original comment by smartm...@gmail.com
on 17 Jan 2011 at 10:24
That's good news anyways, because I thought that there are other problems, as
well. But I didn't spend too much effort on testing it, since IE9 is still in
beta-state.
Original comment by Uli.He...@googlemail.com
on 18 Jan 2011 at 1:08
Well, __define(G/S)etter__ was easier to implement in the converter. The old
version loops through an array of class members, which requires that setter and
getter can be defined independently.
However, the new version (work in progress) uses another concept: The
parser-output is being processed by javscript-object queries using JsonPath.
If the properties are the only problem then I think it is worth the effort.
I'll try to rename the ticket. The current title isn't meaningful enough.
Original comment by Uli.He...@googlemail.com
on 18 Jan 2011 at 1:47
- Changed title: IE9 errors due to EcmaScript 5 incompatble getters/setters
- Changed state: Accepted
This issue was closed by revision r21.
Original comment by Uli.He...@googlemail.com
on 23 Jan 2011 at 4:36
- Changed state: Fixed
note that IE9 still doesn't work properly, i.e. it behaves differently compared
to other browsers. This should be reported in a new ticket.
Original comment by Uli.He...@googlemail.com
on 23 Jan 2011 at 4:40
This does not appear to have been fixed, until an official fix is provided, I
have replaced the properties in the current version (as of 18/03/11) with
getter/setter pairs, seems to be working in the latest release of IE9.
This should be a top priority issue! IE still holds a large user base
Original comment by weesal...@hotmail.com
on 18 Mar 2011 at 12:33
Attachments:
This was fixed on Jan 23 by revision r21. Due to strange IE9 behavior and few
feedback I didn't provide a new official release (in the downloads section).
Original comment by Uli.He...@googlemail.com
on 18 Mar 2011 at 12:49