Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Object created from a "class" object from ES6 has it's functions broken after page F5



Using SugarCube 2.7.1, compiled with TweeGo 0.99.0, tested on Chrome 51.0 (64bit)

It seems object defined with ES6 class keywords gets murdered when pressing F5. It's content seems to be find, but the prototype is completely overriden by what looks to be Object's.

Sample implementation
:: Db [script]

window.ns = {};//namespace
window.ns.Db = class NpcDb { 
    constructor() {
        this.value = 100;
    }
    giveValue() {
        return this.value;
    }
}

In init:
:: StoryInit
<<set $db to new ns.Db()>>

In passage:
:: Sample [nobr]
Test.
<<print $db.giveValue()>>

First load:
Test. 100
Via Chrome Developper Console
Object.getOwnPropertyNames(SugarCube.State.active.variables.db.__proto__);
["constructor", "giveValue"]

Then I press F5.
Test. Error: <<print>>: bad evaluation: State.variables.db.giveValue is not a function
Object.getOwnPropertyNames(SugarCube.State.active.variables.db.__proto__);
["hasOwnProperty", "constructor", "toString", "toLocaleString", "valueOf", "isPrototypeOf", "propertyIsEnumerable", "__defineGetter__", "__lookupGetter__", "__defineSetter__", "__lookupSetter__", "__proto__"]

What could I do to not have $db butchered? Is there a problem with SugarCube 2.7.1, TweeGo 0.99.0 and these ES6 keywords?
Sign In or Register to comment.