-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
babel-loader (webpack)
Input code
function proxyObserver(component) {
for (let key in component.properties)
if (component.properties[key].observer) {
let base = component.properties[key].observer;
component.properties[key].observer = () => {
// console.log("key", key);
base.apply(this);
};
}
return component;
}Configuration file name
No response
Configuration
No response
Current and expected behavior
local variable base is not captured into closure. note that when variable key is used in closure, it'll work as expected.
current behavior
function proxyObserver(component) {
var _this = this;
for (var key in component.properties) if (component.properties[key].observer) {
var base = component.properties[key].observer;
component.properties[key].observer = function () {
// console.log("key", key);
base.apply(_this);
};
}
return component;
}expected behavior
function proxyObserver(component) {
var _this = this;
var _loop = function _loop(key) {
if (component.properties[key].observer) {
var base = component.properties[key].observer;
component.properties[key].observer = function () {
// console.log("key", key);
base.apply(_this);
};
}
};
for (var key in component.properties) {
_loop(key);
}
return component;
}Environment
babel playground
Possible solution
seem like only for in is not working
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue