Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkasztelnik/5a2b0b548166def2932b67fe82361b2b to your computer and use it in GitHub Desktop.
Save mkasztelnik/5a2b0b548166def2932b67fe82361b2b to your computer and use it in GitHub Desktop.
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