Skip to content

Commit 5c7c6b0

Browse files
committed
use shadowroot.host instead of weakmap
1 parent 2a0fef3 commit 5c7c6b0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/targetable.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ const [targets, getTargets, initializeTargets] = createMark<Element>(
5656

5757
function setTarget(el: Element, controller: Element | ShadowRoot, tag: string, key: string): void {
5858
const get = tag === 'data-targets' ? getTargets : getTarget
59-
if (controller instanceof ShadowRoot) {
60-
controller = controllers.get(controller)!
61-
}
59+
if (controller instanceof ShadowRoot) controller = controller.host
60+
6261
if (controller && get(controller)?.has(key)) {
6362
;(controller as unknown as Record<PropertyKey, unknown>)[key] = {}
6463
}
@@ -67,7 +66,6 @@ function setTarget(el: Element, controller: Element | ShadowRoot, tag: string, k
6766
registerTag('data-target', (str: string) => str.split('.'), setTarget)
6867
registerTag('data-targets', (str: string) => str.split('.'), setTarget)
6968
const shadows = new WeakMap<Element, ShadowRoot>()
70-
const controllers = new WeakMap<ShadowRoot, Element>()
7169

7270
const findTarget = (controller: Element, selector: string, many: boolean) => () => {
7371
const nodes = []
@@ -113,7 +111,6 @@ export const targetable = createAbility(
113111
[attachShadowCallback](root: ShadowRoot) {
114112
super[attachShadowCallback]?.(root)
115113
shadows.set(this, root)
116-
controllers.set(root, this)
117114
observeElementForTags(root)
118115
}
119116
}

0 commit comments

Comments
 (0)