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: proxy-less env support #171

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/v8n.js
Expand Up @@ -40,16 +40,16 @@ function proxyContext(context) {
}

function proxyContextEs5(context) {
const buildRuleSet = ruleSet =>
const addRuleSet = (ruleSet, targetContext) =>
Object.keys(ruleSet).forEach(prop => {
context[prop] = (...args) => {
const newContext = proxyContextEs5(context._clone());
targetContext[prop] = (...args) => {
const newContext = proxyContextEs5(targetContext._clone());
return newContext._applyRule(ruleSet[prop], prop)(...args);
};
});
sbarfurth marked this conversation as resolved.
Show resolved Hide resolved

buildRuleSet(availableRules);
buildRuleSet(customRules);
addRuleSet(availableRules, context);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned, changed context should be reassigned here. otherwise the context variable is changed below and it's not clear where. So it should be clearly reassigned.

addRuleSet(customRules, context);

Object.keys(availableModifiers).forEach(prop => {
Object.defineProperty(context, prop, {
Expand Down