* Determine whether a value under the object meets the conditions for hooking * Note: Having hook conditions and being able to directly modify the value are two different things. * When hooking, also check whether descriptor.writable is false. * If it is false, it must be changed to true
(parentObj, keyName)
| 320 | * @returns {boolean} |
| 321 | */ |
| 322 | isAllowHook (parentObj, keyName) { |
| 323 | /* Some objects will set getters so that an error will be thrown when reading the value, |
| 324 | so try catch is needed to determine whether the attribute can be read normally */ |
| 325 | try { if (!parentObj[keyName]) return false } catch (e) { return false } |
| 326 | const descriptor = Object.getOwnPropertyDescriptor(parentObj, keyName) |
| 327 | return !(descriptor && descriptor.configurable === false) |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * hook core function |