Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused currentContext #1717

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions packages/@lwc/engine/src/framework/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ export interface Context {
tplCache?: Template;
[key: string]: any;
}

export let currentContext: Context = {};

export function establishContext(ctx: Context) {
currentContext = ctx;
}
36 changes: 7 additions & 29 deletions packages/@lwc/engine/src/framework/invoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { assert, isFunction, isUndefined } from '@lwc/shared';
import { currentContext, establishContext } from './context';

import { evaluateTemplate, Template, setVMBeingRendered, getVMBeingRendered } from './template';
import { VM, UninitializedVM, runWithBoundaryProtection } from './vm';
Expand All @@ -20,35 +19,26 @@ export let vmBeingConstructed: UninitializedVM | null = null;
export function isBeingConstructed(vm: VM): boolean {
return vmBeingConstructed === vm;
}
const noop = () => void 0;

export function invokeComponentCallback(vm: VM, fn: (...args: any[]) => any, args?: any[]): any {
const { component, callHook, context, owner } = vm;
const ctx = currentContext;
const { component, callHook, owner } = vm;
let result;
runWithBoundaryProtection(
vm,
owner,
() => {
// pre
establishContext(context);
},
noop,
() => {
// job
result = callHook(component, fn, args);
},
() => {
// post
establishContext(ctx);
}
noop
);
return result;
}

export function invokeComponentConstructor(vm: UninitializedVM, Ctor: ComponentConstructor) {
const vmBeingConstructedInception = vmBeingConstructed;
const { context } = vm;
const ctx = currentContext;
establishContext(context);
let error;
if (process.env.NODE_ENV !== 'production') {
startMeasure('constructor', vm);
Expand All @@ -75,7 +65,6 @@ export function invokeComponentConstructor(vm: UninitializedVM, Ctor: ComponentC
} catch (e) {
error = Object(e);
} finally {
establishContext(ctx);
if (process.env.NODE_ENV !== 'production') {
endMeasure('constructor', vm);
}
Expand All @@ -93,10 +82,8 @@ export function invokeComponentRenderMethod(vm: VM): VNodes {
def: { render },
callHook,
component,
context,
owner,
} = vm;
const ctx = currentContext;
const isRenderBeingInvokedInception = isInvokingRender;
const vmBeingRenderedInception = getVMBeingRendered();
let html: Template;
Expand All @@ -106,7 +93,6 @@ export function invokeComponentRenderMethod(vm: VM): VNodes {
owner,
() => {
// pre
establishContext(context);
isInvokingRender = true;
setVMBeingRendered(vm);
},
Expand All @@ -119,7 +105,6 @@ export function invokeComponentRenderMethod(vm: VM): VNodes {
},
() => {
// post
establishContext(ctx);
isInvokingRender = isRenderBeingInvokedInception;
setVMBeingRendered(vmBeingRenderedInception);
}
Expand All @@ -134,15 +119,11 @@ export function invokeEventListener(
thisValue: undefined | ComponentInterface,
event: Event
) {
const { callHook, owner, context } = vm;
const ctx = currentContext;
const { callHook, owner } = vm;
runWithBoundaryProtection(
vm,
owner,
() => {
// pre
establishContext(context);
},
noop,
() => {
// job
if (process.env.NODE_ENV !== 'production') {
Expand All @@ -153,9 +134,6 @@ export function invokeEventListener(
}
callHook(thisValue, fn, [event]);
},
() => {
// post
establishContext(ctx);
}
noop
);
}