Add scope selector value

This commit is contained in:
Adrien Maston
2026-03-17 11:57:59 +01:00
parent 0b29a67e17
commit 2d1e201946
2 changed files with 7 additions and 6 deletions
@@ -2,10 +2,13 @@ import { BridgeComponent } from "@hotwired/hotwire-native-bridge"
export default class extends BridgeComponent {
static component = "stamp"
static values = { scopeSelector: { type: String, default: "body" } }
connect() {
super.connect()
this.notifyBridgeOfConnect()
if (this.element.closest(this.scopeSelectorValue)) {
super.connect()
this.send("connect", this.#data)
}
}
disconnect() {
@@ -13,10 +16,6 @@ export default class extends BridgeComponent {
this.send("disconnect")
}
notifyBridgeOfConnect() {
this.send("connect", this.#data)
}
get #data() {
const bridgeElement = this.bridgeElement
return {