When you run a piece of code (taken from an MDN page regarding a keyword letin ES2015) using the online Babel transpiler , it fails with the following error:
repl: We found a path that isn't a NodePath instance. Possiblly due to bad serialisation.
the code
var list = document.getElementById("list");
for (var i = 1; i <= 5; i++) {
var item = document.createElement("LI");
item.appendChild(document.createTextNode("Item " + i));
let j = i;
item.onclick = function (ev) {
console.log("Item " + j + " is clicked.");
};
list.appendChild(item);
}
Why does an error occur and what can I do?
source
share