highlightjs-badge
highlightjs-badge copied to clipboard
recommend an option for a `root`
current it is assumed that contentSelector
will be applied to document
. this is a fine assumption but i suggest that you be able to specify root
as an option so that the badge can be added by those using an adhoc approach (e.g. a mutationObserver).
- in options set the
root
by default to document. - suggest a check in
load
to make sureroot
is eligible:
if(root !== document || !(root instanceof Element))
throw new TypeError('root element is neither document nor an element')
- There are only a couple of lines where you would need to change
document.querySelector
toroot.querySelector