2020-01-15 21:18:02 +01:00
|
|
|
class DetailsHighlighter {
|
|
|
|
|
|
|
|
constructor(elem) {
|
|
|
|
this.elem = elem;
|
|
|
|
this.dealtWith = false;
|
|
|
|
elem.addEventListener('toggle', this.onToggle.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
onToggle() {
|
|
|
|
if (this.dealtWith) return;
|
|
|
|
|
2022-02-08 12:10:01 +01:00
|
|
|
if (this.elem.querySelector('pre')) {
|
|
|
|
window.importVersioned('code').then(Code => {
|
|
|
|
Code.highlightWithin(this.elem);
|
|
|
|
});
|
|
|
|
}
|
2020-01-15 21:18:02 +01:00
|
|
|
this.dealtWith = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DetailsHighlighter;
|