nico3333fr / jquery-accessible-accordion-aria

jQuery Accessible Accordion System, using ARIA
MIT License
60 stars 19 forks source link

Page-breaking JavaScript error when using jQuery 3.x #33

Closed LordPachelbel closed 5 years ago

LordPachelbel commented 5 years ago

When using jQuery 3.x, calling $('.js-accordion').accordion(); causes the following error:

TypeError: can't assign to property "guid" on ".js-accordion__panel": not an object debugger eval code:2:39624

(That's Firefox dev edition's wording.)

After this error occurs, the accordions still work — you can click on them and they will expand and collapse just fine — but any other jQuery code that comes after the .accordion() call will fail to run, which can break the page if jQuery is supposed to do anything else after the accordions are created.

My browser debugger shows that line 101 of the plugin triggers the error: this.$buttons = $(this.options.buttonsSelector, this.$wrapper);

The error happens inside jQuery 3.x's jQuery.event object's helper function .add(), on lines 4976-4979:

// Make sure that the handler has a unique ID, used to find/remove it later
if ( !handler.guid ) {
  handler.guid = jQuery.guid++;
}

Edit: The 3.x version of the jQuery Migrate plugin doesn't fix the problem.

t-fulton commented 5 years ago

I'm having the same issue

nwjlyons commented 5 years ago

I'm also having this problem. Did you find a fix?

nwjlyons commented 5 years ago

Downgrading jquery-accessible-accordion-aria to version 2.5.2 fixed this issue for me.

ryuran commented 5 years ago

The answer should be somewhere in it https://jquery.com/upgrade-guide/3.0/ I'have no idea at this time.

mosne commented 5 years ago

putting in comment ` // this.$wrapper.on('keydown', this.options.buttonsSelector, $.proxy(this.keydownButtonEventHandler, this));

//  this.$wrapper.on('keydown', this.options.panelsSelector, $.proxy(this.keydownPanelEventHandler, this));

` solved the issue with jquery 3.x

ryuran commented 5 years ago

So it's related to #35

nico3333fr commented 5 years ago

Sorry for delay (really too busy): it is fixed via https://github.com/nico3333fr/jquery-accessible-accordion-aria/commit/f526a457179834392375cc313bbcafff6f335cbf