From 4ba7d3c24462c57e2e085c2028512425eda4dc36 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 24 May 2014 03:27:25 +0200 Subject: [PATCH] jquery.makeCollapsible: Use .prop() for value attribute of list item The issue with "value" attributes is popularised through form fields (e.g. change value with prop, because it doesn't work with attribute, attributes only change the DOM, not the live rendering). However the attribute/property issue isn't limited to form fields and the typical value/selected/disabled properties . It applies to all properties and for any element that affects active state (if it changes the display, one should use a property, not an attribute). As far as I know, unlike for form fields, browsers do actually synchronise attributes in the many of those cases (including list items), so there is no immediate danger. But since it's caught by jQuery Migrate and a good practice regardless, change it to use prop() as well. To test: https://test.wikipedia.org/?oldid=199994#head-collapsible-ol Change-Id: I246c26bd2958209feed73fc2ef31cf678b12fa3b --- resources/src/jquery/jquery.makeCollapsible.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/src/jquery/jquery.makeCollapsible.js b/resources/src/jquery/jquery.makeCollapsible.js index 314d518093..05745f8bbb 100644 --- a/resources/src/jquery/jquery.makeCollapsible.js +++ b/resources/src/jquery/jquery.makeCollapsible.js @@ -351,9 +351,9 @@ // Make sure the numeral order doesn't get messed up, force the first (soon to be second) item // to be "1". Except if the value-attribute is already used. // If no value was set WebKit returns "", Mozilla returns '-1', others return 0, null or undefined. - firstval = $firstItem.attr( 'value' ); + firstval = $firstItem.prop( 'value' ); if ( firstval === undefined || !firstval || firstval === '-1' || firstval === -1 ) { - $firstItem.attr( 'value', '1' ); + $firstItem.prop( 'value', '1' ); } $toggleLink = buildDefaultToggleLink(); $toggleLink.wrap( '
  • ' ).parent().prependTo( $collapsible ); -- 2.20.1