Closed mvantassel closed 9 years ago
@mvantassel thanks for reporting! When exactly does this error show up?
Hey, I'm seeing it in my unit tests for my implementation. The view that contains the range slider is rendered and available when instantiating but for some reason is null when it gets to that method. I'll get you a stack trace soon. AFK Thanks!
Hey,
Here is some more information. Unfortunately I can't show you the implementation but know that the element that the jquery plugin is attached to does exist in the dom.
Uncaught TypeError: Cannot read property 'offsetWidth' of null
isHidden
getHiddenParentNodes
getDimension
Plugin.update
Plugin.init
Plugin
in getHiddenParentNodes, ‘element’ is:
div.rangeslider__handle
when the tests pass ‘element’ is:
<div class="rangeslider" id="js-rangeslider-9" style=""><div class="rangeslider__fill"></div><div class="rangeslider__handle"></div></div>
This looks to be a race condition in rangeslider when it builds the component
I ran across this as well, same error message, and same element causing the problem in getHiddenParentNodes
. For me, it happened when I created a slider with value of zero, as in this line when attribute['weight'] = 0
:
return '<div class="round-rect"><input class="slider" id="slider' + attribute['id'] + '" type="range" min="0" max="10" value="' + attribute['weight'] + '" step="0.1" /></div>';
my fix was changing the isHidden
function:
function isHidden(element) {
if (//sh - added 4/17
!element) {
return false;
};
if (element.offsetWidth === 0 ||
element.offsetHeight === 0 ||
// Also Consider native `<details>` elements.
element.open === false) {
return true;
}
return false;
}
Hey guys @mvantassel @samhavens pr #144 should fix this issue. Can you pls give me a feedback? Cheers! :v:
@andreruffert Looks good to me! :+1:
Madd! Thanks for the double check! :ok_hand: Will be in the next Release v1.2.1
Works perfect. That's the change I added to my fork. Thanks @andreruffert !
TypeError: 'null' is not an object (evaluating 'element.offsetWidth')