mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 01:34:29 +01:00
With Options::es2015, vectorcraft-js reads and runs ECMAScript 2015 classes: declarations, scoped to their block like let, and expressions, with extends, static members, getters and setters and computed method names. Class code is strict mode code, methods are not enumerable and cannot be constructed, and calling a class without new throws a TypeError. A derived constructor's this throws a ReferenceError until super(...) returns, and its default constructor passes its arguments on. super.name and super[key] read, call and write through the prototype of the method's home object, in class methods and in object literal methods, which ES2015 allows in a .js script. new.target names the constructor new was applied to, in functions and their arrow functions. A class can extend null, a function, a class, or the built-in constructors Object, Function, Array, String, Number, Boolean, RegExp, Date and the error types; extending any other built-in throws a TypeError. Each class and method takes fuel and counts against the heap limit, and deep constructor chains stop at the frame limit. A .jsx file and a source string stay ES5.1, where class syntax is a SyntaxError. The test262 runner adds the class, super and new.target tests to its ES2015 subset (1,125 tests). With the option, 554 of 554 negative parse runs and 1,527 of 1,633 other runs pass; the failing runs use Object.setPrototypeOf, RegExp.prototype.flags, function name properties, a configurable length, the caller and arguments restrictions, or super and new.target in direct eval. Docs: docs/mcp.md, docs/target-app-parity.md.