Forked from julianrubisch/highlight_anchor_controller.js
Created
December 6, 2022 11:09
-
-
Save mkasztelnik/5a2b0b548166def2932b67fe82361b2b 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