GNOME Bugzilla – Bug 778718
Lang.Class should include symbol properties
Last modified: 2017-02-26 21:54:45 UTC
I'm pretty sure the following should work: const Klass = new Lang.Class({ Name: 'Klass', *[Symbol.iterator]() { yield* [1, 2, 3]; }, }); let instance = new Klass(); print([...instance]); But instead, "TypeError: instance[Symbol.iterator] is not a function" I think this is because Lang.copyProperties() does not copy symbol properties by default.
Created attachment 346718 [details] [review] lang: Copy symbol properties into class prototype Now that our JS engine supports symbols, we need to make sure that our class framework supports properties with symbol keys. Previously we would copy properties from the object passed to Lang.Class (the "params object") onto the class's prototype using Object.getOwnPropertyNames(). Now we need to use Object.getOwnPropertySymbols() as well, so that properties and methods with symbol keys are copied. One common use case might be making an object iterable by giving it a Symbol.iterator method.
Review of attachment 346718 [details] [review]: Thanks, looks good.
Attachment 346718 [details] pushed as 74bf3bd - lang: Copy symbol properties into class prototype