(obj: any, prop: string, prototype?: any)
| 419 | |
| 420 | it('should patch all possible on properties on native prototype', function () { |
| 421 | function isPropertyPatched(obj: any, prop: string, prototype?: any) { |
| 422 | let desc = Object.getOwnPropertyDescriptor(obj, prop); |
| 423 | if (!desc && prototype) { |
| 424 | // when patch window object, use prototype to check prop exist or not |
| 425 | const prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); |
| 426 | if (prototypeDesc) { |
| 427 | desc = {enumerable: true, configurable: true}; |
| 428 | } |
| 429 | } |
| 430 | // if the descriptor not exists or is not configurable |
| 431 | // just return |
| 432 | if (!desc || !desc.configurable) { |
| 433 | return true; |
| 434 | } |
| 435 | |
| 436 | const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); |
| 437 | if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { |
| 438 | return true; |
| 439 | } |
| 440 | return false; |
| 441 | } |
| 442 | |
| 443 | function isPropertiesPatched(obj: any, properties: string[] | null, prototype?: any) { |
| 444 | if (properties) { |
no outgoing calls
no test coverage detected
searching dependent graphs…