(node: Node, module: SourceModule)
| 1264 | // `Object.getPrototypeOf([]).first = fn`, `[].__proto__.first = fn`, or |
| 1265 | // `const { prototype } = Array` — rather than `Array.prototype.slice.call(list)` |
| 1266 | const isBuiltinPrototypePatch = (node: Node, module: SourceModule): boolean => { |
| 1267 | if ( |
| 1268 | node.type === "MemberExpression" && |
| 1269 | memberNameOf(node) === "prototype" && |
| 1270 | isBuiltinCtor(node.object, module) |
| 1271 | ) { |
| 1272 | const [operand, parent] = operatorOf(node) |
| 1273 | return !isSafePrototypeRead(operand, parent) |
| 1274 | } |
| 1275 | if (isBuiltinCtor(node, module)) { |
| 1276 | const [operand, parent] = operatorOf(node) |
| 1277 | if ( |
| 1278 | parent?.type === "VariableDeclarator" && |
| 1279 | parent.init === operand && |
| 1280 | destructuresPrototype(parent.id) |
| 1281 | ) |
| 1282 | return true |
| 1283 | if ( |
| 1284 | parent?.type === "AssignmentExpression" && |
| 1285 | parent.right === operand && |
| 1286 | destructuresPrototype(parent.left) |
| 1287 | ) |
| 1288 | return true |
| 1289 | if ( |
| 1290 | parent?.type === "CallExpression" && |
| 1291 | parent.arguments[0] === operand && |
| 1292 | globalNameOf(unwrapExpression(parent.callee), module)?.endsWith( |
| 1293 | "getOwnPropertyDescriptor" |
| 1294 | ) |
| 1295 | ) |
| 1296 | return true |
| 1297 | } |
| 1298 | if ( |
| 1299 | node.type === "CallExpression" && |
| 1300 | isGetPrototypeOfCallee(node.callee, module) |
| 1301 | ) { |
| 1302 | const [operand, parent] = operatorOf(node) |
| 1303 | if ( |
| 1304 | (parent?.type === "MemberExpression" && |
| 1305 | parent.object === operand && |
| 1306 | isWriteTarget(parent)) || |
| 1307 | isPrototypeMutatorCall(operand, parent, module) |
| 1308 | ) |
| 1309 | return true |
| 1310 | if (isArrayOrObjectLiteral(node.arguments[0])) |
| 1311 | return !isSafePrototypeRead(operand, parent) |
| 1312 | } |
| 1313 | if ( |
| 1314 | node.type === "MemberExpression" && |
| 1315 | memberNameOf(node) === "__proto__" && |
| 1316 | !isWriteTarget(node) |
| 1317 | ) { |
| 1318 | const [operand, parent] = operatorOf(node) |
| 1319 | if ( |
| 1320 | (parent?.type === "MemberExpression" && |
| 1321 | parent.object === operand && |
| 1322 | isWriteTarget(parent)) || |
| 1323 | isPrototypeMutatorCall(operand, parent, module) |
no test coverage detected