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) {
this.word("react");
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")) {
this.next();
const node = this.startNode();
node.body = this.parseStatement();
node.bodyProc = this.parseSyntheticFunctionStatement();
return this.finishNode(node, "SyndicateReactStatement");
}

View File

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

View File

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