File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,8 @@ export function GridStackProvider({
7272
7373 const removeWidget = useCallback (
7474 ( id : string ) => {
75- const element = document . body . querySelector ( `[gs-id="${ id } "]` ) ;
76-
77- if ( element ) {
78- gridStack ?. removeWidget ( element as GridItemHTMLElement ) ;
79- }
75+ const element = document . body . querySelector < GridItemHTMLElement > ( `[gs-id="${ id } "]` ) ;
76+ if ( element ) gridStack ?. removeWidget ( element ) ;
8077
8178 setRawWidgetMetaMap ( ( prev ) => {
8279 const newMap = new Map < string , GridStackWidget > ( prev ) ;
Original file line number Diff line number Diff line change @@ -82,9 +82,9 @@ export interface GridItemHTMLElement extends HTMLElement {
8282
8383/**
8484 * Type representing various ways to specify grid elements.
85- * Can be a CSS selector string, HTMLElement, or GridItemHTMLElement .
85+ * Can be a CSS selector string, GridItemHTMLElement (HTML element with GS variables when loaded) .
8686 */
87- export type GridStackElement = string | HTMLElement | GridItemHTMLElement ;
87+ export type GridStackElement = string | GridItemHTMLElement ;
8888
8989/**
9090 * Event handler function types for the .on() method.
Original file line number Diff line number Diff line change @@ -123,8 +123,17 @@ export class Utils {
123123
124124 let list = root . querySelectorAll ( els ) ;
125125 if ( ! list . length && els [ 0 ] !== '.' && els [ 0 ] !== '#' ) {
126+ // see if mean to be a class
126127 list = root . querySelectorAll ( '.' + els ) ;
127- if ( ! list . length ) { list = root . querySelectorAll ( '#' + els ) }
128+
129+ // else if mean to be an id
130+ if ( ! list . length ) list = root . querySelectorAll ( '#' + els ) ;
131+
132+ // else see if gs-id attribute
133+ if ( ! list . length ) {
134+ const el = root . querySelector < HTMLElement > ( `[gs-id="${ els } "]` ) ;
135+ return el ? [ el ] : [ ] ;
136+ }
128137 }
129138 return Array . from ( list ) as HTMLElement [ ] ;
130139 }
You can’t perform that action at this time.
0 commit comments