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: Capture let when the for body is not a block #16368

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions packages/babel-plugin-transform-block-scoping/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ export default declare((api, opts: Options) => {
let bodyScope: Scope | null;
if (body.isBlockStatement()) {
bodyScope = body.scope;

const bindings = getLoopBodyBindings(path);
for (const binding of bindings) {
const { capturedInClosure } = getUsageInBody(binding, path);
if (capturedInClosure) markNeedsBodyWrap();
}
}
const bindings = getLoopBodyBindings(path);
for (const binding of bindings) {
const { capturedInClosure } = getUsageInBody(binding, path);
if (capturedInClosure) markNeedsBodyWrap();
}

const captured: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function proxyObserver(component) {
for (let key in component.properties)
if (component.properties[key].observer) {
let base = component.properties[key].observer;
component.properties[key].observer = () => {
base.apply(this);
};
}

return component;
}

function proxyObserver2(component) {
for (let key of component.properties)
while (1) {
let base = component.properties[key].observer;
component.properties[key].observer = () => {
base.apply(this);
};
}

return component;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function proxyObserver(component) {
var _this = this;
var _loop = function () {
if (component.properties[key].observer) {
var base = component.properties[key].observer;
component.properties[key].observer = function () {
base.apply(_this);
};
}
};
for (var key in component.properties) {
_loop();
}
return component;
}
function proxyObserver2(component) {
var _this2 = this;
for (var key of component.properties) {
var _loop2 = function () {
var base = component.properties[key].observer;
component.properties[key].observer = function () {
base.apply(_this2);
};
};
while (1) {
_loop2();
}
}
return component;
}