Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@cb2b31e6f1] [MERGE #3892 @boingoing] To…
Browse files Browse the repository at this point in the history
…p level event handlers have an implicit 'this' binding

Merge pull request #3892 from boingoing:ImplicitThisForEventHandler
  • Loading branch information
chakrabot authored and kfarnung committed Jan 9, 2018
1 parent d96063d commit 4bd8e0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion deps/chakrashim/core/lib/Parser/Parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,10 +1682,12 @@ void Parser::CreateSpecialSymbolDeclarations(ParseNodePtr pnodeFnc, bool isGloba
{
Assert(!(isGlobal && (this->m_grfscr & fscrEval)));

bool isTopLevelEventHandler = (this->m_grfscr & fscrImplicitThis || this->m_grfscr & fscrImplicitParents);

// Create a 'this' symbol for global lambda, indirect eval, ordinary functions with references to 'this', and all class constructors.
PidRefStack* ref = wellKnownPropertyPids._this->GetTopRef();
if (((pnodeFnc->sxFnc.IsLambda() && GetCurrentNonLambdaFunctionNode() == nullptr && !(this->m_grfscr & fscrEval)) || !pnodeFnc->sxFnc.IsLambda())
&& ((ref && ref->GetScopeId() >= m_currentBlockInfo->pnodeBlock->sxBlock.blockId) || pnodeFnc->sxFnc.IsClassConstructor()))
&& ((ref && ref->GetScopeId() >= m_currentBlockInfo->pnodeBlock->sxBlock.blockId) || pnodeFnc->sxFnc.IsClassConstructor() || isTopLevelEventHandler))
{
// Insert the decl for 'this'
ParseNodePtr thisNode = this->CreateSpecialVarDeclNode(pnodeFnc, wellKnownPropertyPids._this);
Expand Down

0 comments on commit 4bd8e0c

Please sign in to comment.