Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Created December 5, 2022 13:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save julianrubisch/9098e7914aceb1c8437a67e376ae2a80 to your computer and use it in GitHub Desktop.
Save julianrubisch/9098e7914aceb1c8437a67e376ae2a80 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