- Notifications
You must be signed in to change notification settings - Fork20.6k
Commit527fb3d
authored
Event: Increase robustness of an inner native event in leverageNative
In Firefox, alert displayed just before blurring an element dispatchesthe native blur event twice which tripped the jQuery logic if a jQuery blurhandler was not attached before the trigger call.This was because the `leverageNative` logic part for triggering first checked ifsetup was done before (which, for example, is done if a jQuery handler wasregistered before for this element+event pair) and - if it was not - addeda dummy handler that just returned `true`. The `leverageNative` logic made that`true` then saved into private data, replacing the previous `saved` array. Since`true` passed the truthy check, the second native inner handler treated `true`as an array, crashing on the `slice` call.The same issue could happen if a handler returning `true` is attached beforetriggering. A bare `length` check would not be enough as the user handler mayreturn an array-like as well. To remove this potential data shape clash, capturethe inner result in an object with a `value` property instead of saving itdirectly.Since it's impossible to call `alert()` in unit tests, simulate the issue byreplacing the `addEventListener` method on a test button with a version thatcalls attached blur handlers twice.Fixesgh-5459Closesgh-5466Refgh-52361 parent5880e02 commit527fb3d
2 files changed
+97
-18
lines changedLines changed: 39 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
519 | 519 |
| |
520 | 520 |
| |
521 | 521 |
| |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
522 | 537 |
| |
523 | 538 |
| |
524 | 539 |
| |
525 |
| - | |
| 540 | + | |
526 | 541 |
| |
527 | 542 |
| |
528 |
| - | |
529 |
| - | |
| 543 | + | |
| 544 | + | |
530 | 545 |
| |
531 | 546 |
| |
532 | 547 |
| |
| |||
541 | 556 |
| |
542 | 557 |
| |
543 | 558 |
| |
544 |
| - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
545 | 566 |
| |
546 | 567 |
| |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 |
| - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
553 | 572 |
| |
554 | 573 |
| |
555 | 574 |
| |
556 | 575 |
| |
557 |
| - | |
558 |
| - | |
559 |
| - | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
560 | 579 |
| |
561 | 580 |
| |
562 |
| - | |
563 |
| - | |
564 |
| - | |
565 |
| - | |
566 |
| - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
567 | 588 |
| |
568 | 589 |
| |
569 | 590 |
| |
|
Lines changed: 58 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3502 | 3502 |
| |
3503 | 3503 |
| |
3504 | 3504 |
| |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
| 3539 | + | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
3505 | 3563 |
| |
3506 | 3564 |
| |
3507 | 3565 |
| |
|
0 commit comments
Comments
(0)