Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7527/ |
| helpers.superPropBase = () => template.program.ast` | ||
| import getPrototypeOf from "getPrototypeOf"; | ||
|
|
||
| export default function _superPropReceiver(object, property) { |
There was a problem hiding this comment.
Looks like this needs a rename to match the helper name.
|
I think that we should add use |
| desc = Object.getOwnPropertyDescriptor(receiver, property); | ||
| if (desc) { | ||
| if (desc.set) { | ||
| if (isStrict()) { |
There was a problem hiding this comment.
Hmm, I wonder if it'd be better to actually pass this as a true/false value to the helper? Since it is the caller's location, not the actual helper that we want to know the strictness of. Especially with #7411 and if we do sourceType:script I'd expect a lot more code to be strict only inside class bodies for instance, so this helper would return the wrong value.
There was a problem hiding this comment.
That'd be great. How do I get that value? The same traversal?
jridgewell
left a comment
There was a problem hiding this comment.
I think that we should add use Reflect.{get, set} where it's possible.
We can go this route as well, though I'd prefer it if we can avoid including all of core-js's polyfills for this one case.
| desc = Object.getOwnPropertyDescriptor(receiver, property); | ||
| if (desc) { | ||
| if (desc.set) { | ||
| if (isStrict()) { |
There was a problem hiding this comment.
That'd be great. How do I get that value? The same traversal?
|
@jridgewell it can be polyfilled without any problems. And it's definitely better if native methods are available. |
|
It'll use the |
| specHandleAssignmentExpression(ref, path, node) { | ||
| if (node.operator === "=") { | ||
| // super.name = "val"; -> _set(Object.getPrototypeOf(objectRef.prototype), "name", this); | ||
| const strictParent = path.findParent(path => { |
There was a problem hiding this comment.
This should also check for class bodies (which are always strict)
|
|
||
| export default function _construct(Parent, args, Class) { | ||
| if (typeof Reflect === "object" && Reflect.construct) { | ||
| if (typeof Reflect !== "undefined" && Reflect.construct) { |
There was a problem hiding this comment.
Isn't "object" better? What if Reflect is a number? that will probably never happen tho.
There was a problem hiding this comment.
typeof X === "object" and === "symbol" requires a typeof helper to compensate for polyfilled Symbol instances.
xtuc
left a comment
There was a problem hiding this comment.
The more we can re-use the better 👍
This was failing because of the bugs fixed by babel#7687.
This was failing because of the bugs fixed by #7687.
Fixes #5769.
Wow, this had all kinds of bug. For instance,
super.set = 1attempted to dodescriptor.value = 1thinking did anything. Whoops.I kinda went overboard matching the spec. We can probably prune it down a bit.