I am working on upgrading big application to latest jQuery 3.0 from pretty ancient 1.11.2. I found pretty subtle change that broke some of our functionality:
when we instantiate some complex widgets, we initially hide some of the elements using css (display none). Then we use show/hide to display the element.
But call to show/hide can happen before widget is attached to DOM. Show/hide used to work fine in 1.11.2 when element was not attached, but does not work in 3.0.0.
Demo:
1.11.2: https://jsfiddle.net/7j9xawc2/1/
.tabCompositeSearchWidget-ClearButton
{
/* Clear button is initially hidden */
display: none;
}
var e = document.createElement('div');
$(e).addClass('tabCompositeSearchWidget-ClearButton');
$(e).text('blah');
$(e).show();
$('#root').append($(e));
alert($(e).is(":visible"));
In the old version element will be visible and alert will say true
, in the most recent it won't be visible and alert will say false
It is hard to find all of such usages and I am interested in the best way of fixing that: what can be the best fix here? Manually modifying jquery.js file to behave it the old way? (I don't really want to do that)
Upd: fixing one-off case is easy. But have potentially tens of such calls and finding & fixing all of them needs huge effort and is not effective.