kylebelanger/range.js

List Manipulation unable to handle double-nested elements

jcquinlan opened this issue · 1 comments

While range.js can be used to control the display of lists and nested lists, it fails to cover any deeper level of nested elements. I somewhat expected this, so I will outline a potential fix, assuming I am correct in my assumption of what the issue is.

Theory: In updateList() I am not recursively exploring this target element, rather I am using hardcoded for loops to search, at most, two layers of the element.

Potential Fix: Write a recursive method similar to searchChildren() that will check for child elements, else it will compare the elements data-position to the current range to dictate it's display property. This will prevent placing a limit in the maximum number of nested elements able to be selectively hidden by the associated range input.

Fixed with patch: 46affd. Can now handle unlimited nested list elements.

Solution: The problem was the data-position and input range values were being treated as strings, and not integers. To fix, I simply parse the range value to an integer in the event listener.