File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {defineObservedAttributes, initializeAttrs} from './attr.js'
55import type { CustomElement } from './custom-element.js'
66
77const instances = new WeakSet < Element > ( )
8+ const symbol = Symbol . for ( 'catalyst' )
89
910export function initializeInstance ( instance : HTMLElement , connect ?: ( this : HTMLElement ) => void ) : void {
1011 instance . toggleAttribute ( 'data-catalyst' , true )
@@ -38,3 +39,18 @@ export function initializeClass(classObject: CustomElement): void {
3839export function initialized ( el : Element ) : boolean {
3940 return instances . has ( el )
4041}
42+
43+ export function meta ( proto : Record < PropertyKey , unknown > , name : string ) : Set < string > {
44+ if ( ! Object . prototype . hasOwnProperty . call ( proto , symbol ) ) {
45+ const parent = proto [ symbol ] as Map < string , Set < string > > | undefined
46+ const map = ( proto [ symbol ] = new Map < string , Set < string > > ( ) )
47+ if ( parent ) {
48+ for ( const [ key , value ] of parent ) {
49+ map . set ( key , new Set ( value ) )
50+ }
51+ }
52+ }
53+ const map = proto [ symbol ] as Map < string , Set < string > >
54+ if ( ! map . has ( name ) ) map . set ( name , new Set < string > ( ) )
55+ return map . get ( name ) !
56+ }
You can’t perform that action at this time.
0 commit comments