I'm currently unable to access my Windows laptop that has Sphere 1.5 on it; can someone with easier access to their 1.5 setup confirm whether or not the Object.defineProperty (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty) method of getters & setters works? I know much of my old Sphere code uses older getters and setters tactics and I'd much rather recommend something more modern and standardized to those who want to raise their JS level.
The Linux and Macintosh 1.6+ versions I have don't have it to be sure, and I pumped the libjs version in my OS X version as high as it would go before API breakage.
So I doubt it.
No, it does not. Sphere 1.5 uses JS 1.5, an incredibly ancient version of SpiderMonkey (2003 according to Sphere editor's About dialog).
Lord English, I noticed you do this sometimes:
function object() {
this.something = getter function() {
}
}
Which is interesting since my ECMA 1.5 compliant SSFML doesn't see that as valid syntax (SpiderMonkey has it's quirks). You could use __defineSetter__() or __defineGetter()__... But again I only added that as a polyfill utilizing Object.defineProperty... so I guess that originally didn't work either, but at least it's a bit more compatible since I'm not keen on adding extra syntax handling to Jurassic's lexical analyzer (const was enough!).
Yeah, prop getter/setter is a non-standard Mozilla way to do it in older SpiderMonkey versions before defineProperty was a thing. It doesn't work anymore in SM either, so no use getting worked up over it. If you see that, it's older code I wrote; I try to avoid it now.
So...yea, three different ways to get/set, but only one is current standard.
Can someone with more time than me get a working Object.defineProperty polyfill? I'm fine with it being prototyped directly onto Object.
It's pretty much impossible to polyfill, so much of its functionality requires hooks in the underlying JS engine that older engines just don't have. Even MDN doesn't list a polyfill for it.