Proper "this" scoping in react{}

This commit is contained in:
Tony Garnock-Jones 2018-11-19 16:57:00 +00:00
parent 71fed1eb48
commit 3dc6559d26
4 changed files with 8 additions and 8 deletions

View File

@ -162,5 +162,5 @@ export function DuringStatement(node) {
export function SyndicateReactStatement(node) { export function SyndicateReactStatement(node) {
this.word("react"); this.word("react");
this.space(); this.space();
this.print(node.body, node); this.printBlock(node.bodyProc);
} }

View File

@ -122,7 +122,7 @@ export default class SyndicateParser extends _original_Parser {
if (this.isContextual("react")) { if (this.isContextual("react")) {
this.next(); this.next();
const node = this.startNode(); const node = this.startNode();
node.body = this.parseStatement(); node.bodyProc = this.parseSyntheticFunctionStatement();
return this.finishNode(node, "SyndicateReactStatement"); return this.finishNode(node, "SyndicateReactStatement");
} }

View File

@ -540,10 +540,10 @@ export default declare((api, options) => {
path.replaceWith(template( path.replaceWith(template(
`DATASPACE._currentFacet.actor.addFacet( `DATASPACE._currentFacet.actor.addFacet(
DATASPACE._currentFacet, DATASPACE._currentFacet,
function () { BODY }, BODYPROC,
true);`)({ true);`)({
DATASPACE: state.DataspaceID, DATASPACE: state.DataspaceID,
BODY: node.body, BODYPROC: node.bodyProc,
})); }));
}, },
}, },

View File

@ -196,12 +196,12 @@ defineType("DuringStatement", {
}); });
defineType("SyndicateReactStatement", { defineType("SyndicateReactStatement", {
builder: ["body"], builder: ["bodyProc"],
visitor: ["body"], visitor: ["bodyProc"],
aliases: ["Statement"], aliases: ["Statement"],
fields: { fields: {
body: { bodyProc: {
validate: assertNodeType("Statement"), validate: assertNodeType("FunctionExpression"),
}, },
}, },
}); });