Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/pmb/node_modules/@babel/preset-modules/src/plugins/transform-safari-for-shadowing/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* Safari ~11 has an issue where variable declarations in a For statement throw if they shadow parameters.
* This is fixed by renaming any declarations in the left/init part of a For* statement so they don't shadow.
* @see https://bugs.webkit.org/show_bug.cgi?id=171041
*
* @example
* e => { for (let e of []) e } // throws
* e => { for (let _e of []) _e } // works
*/
function handle(declaration) {
if (!declaration.isVariableDeclaration()) return;
const fn = declaration.getFunctionParent();
const { name } = declaration.node.declarations[0].id;
// check if there is a shadowed binding coming from a parameter
if (
fn &&
fn.scope.hasOwnBinding(name) &&
fn.scope.getOwnBinding(name).kind === "param"
) {
declaration.scope.rename(name);
}
}
export default () => ({
name: "transform-safari-for-shadowing",
visitor: {
ForXStatement(path) {
handle(path.get("left"));
},
ForStatement(path) {
handle(path.get("init"));
},
},
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0066 ]-- |