mathiasbynens / jquery-details

World’s first <details>/<summary> polyfill™
https://mths.be/details
GNU General Public License v2.0
121 stars 34 forks source link

Set open attr, not just prop #20

Open singpolyma opened 10 years ago

singpolyma commented 10 years ago

The spec defines an "open" attribute for showing the details as open/closed -- but only a prop is set by this fill-in, relying on a class fallback for selection/styling

MadLittleMods commented 8 years ago

:+1:

It seems to work just fine if you swap prop for attr.

toggleOpen = function($details, $detailsSummary, $detailsNotSummary, toggle) {
    var isOpen = $details.attr('open'),
        close = isOpen && toggle || !isOpen && !toggle;
    if (close) {
        $details.removeClass('open').attr('open', false).triggerHandler('close.details');
        $detailsSummary.attr('aria-expanded', false);
        $detailsNotSummary.hide();
    } else {
        $details.addClass('open').attr('open', true).triggerHandler('open.details');
        $detailsSummary.attr('aria-expanded', true);
        $detailsNotSummary.show();
    }
};
WebDragon commented 8 years ago

http://api.jquery.com/prop/ presumably there was a reason prop was used instead of attr

pthorson commented 4 years ago

http://api.jquery.com/prop/ presumably there was a reason prop was used instead of attr

Specifically support for newer jQuery version: https://github.com/mathiasbynens/jquery-details/commit/3cc7fc6c6868570d614a217c316db6cf5dd451f5#diff-b76a01b9ccf8cf65939d876b7f8d079f