Created
December 5, 2022 13:24
-
-
Save julianrubisch/9098e7914aceb1c8437a67e376ae2a80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from '@hotwired/stimulus' | |
export default class extends Controller { | |
static classes = ['highlight'] | |
connect () { | |
this.element | |
.querySelector(`a[name='${window.location.hash.slice(1)}']`) | |
?.parentElement?.classList?.add(...this.highlightClasses) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment