Closed
Description
Related a few issues, but mainly #535
Here is the list of $
occurences in the source code [1].
- The selectors can be replaced by
.querySelectorAll
and.querySelector
on()
can be replaced byaddEventListener
cookie()
can be somewhat easily reimplementedremoveClass()
can be replaced by.style.cssText = .style.cssText.replace(/\bClass\b/)
hide()
can be replaced by.style.display = 'none'
show()
can be replaced by.style.display = 'initial'
parent()
can be replaced by.parentNode
.html()
can be replaced by.innerHTML
.find()
can be replaced by.querySelectorAll
.text()
can be replaced by.innerText
.addClass()
can be replaced by+= ' Class'
.trigger()
can be replaced bydispatchEvent()
toggle()
can be replaced by a.style.display = .style.display === 'none' ? 'initial' : 'none'
is()
is a bit harder to replace, but the selector is always:visible
, so.style.display !== 'none'
etc, etc
Removing jQuery from the dependencies would have multiple benefits :
- No conflict with users environments (which would be great, since it would make the Debug Toolbar a lot less obtrusive)
- A lot less code, and better performances overall (since there is relatively few jQuery use cases in the current codebase)
- No vendors to ship
And the following disadvantages :
- We would have to maintain the very small library which would reimplement jQuery functionalities
- It could break on some browser versions
Overall, I think it would be for the best : the Debug Toolbar is a debug component, and the developers can use a modern browser to use it. Since no client will ever see it, the compatibility issue isn't very relevant.
[1]
grep -R '\$' /usr/local/lib/python2.7/dist-packages/debug_toolbar/static/debug_toolbar/js/ | grep -Po '\.[a-zA-Z]+\(' | sort | uniq -c | sort -gr