Skip to content

Commit 3ab632d

Browse files
Discard changes to src/utils.ts
1 parent fa07d43 commit 3ab632d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class Utils {
5656
/** convert a potential selector into actual list of html elements. optional root which defaults to document (for shadow dom) */
5757
static getElements(els: GridStackElement, root: HTMLElement | Document = document): HTMLElement[] {
5858
if (typeof els === 'string') {
59-
const doc = ('getElementById' in (root || {})) ? root as Document : undefined;
59+
const doc = ('getElementById' in root) ? root as Document : undefined;
6060

6161
// Note: very common for people use to id='1,2,3' which is only legal as HTML5 id, but not CSS selectors
6262
// so if we start with a number, assume it's an id and just return that one item...
@@ -66,10 +66,10 @@ export class Utils {
6666
return el ? [el] : [];
6767
}
6868

69-
let list = root?.querySelectorAll(els);
69+
let list = root.querySelectorAll(els);
7070
if (!list.length && els[0] !== '.' && els[0] !== '#') {
71-
list = root?.querySelectorAll('.' + els);
72-
if (!list.length) { list = root?.querySelectorAll('#' + els) }
71+
list = root.querySelectorAll('.' + els);
72+
if (!list.length) { list = root.querySelectorAll('#' + els) }
7373
}
7474
return Array.from(list) as HTMLElement[];
7575
}
@@ -79,13 +79,13 @@ export class Utils {
7979
/** convert a potential selector into actual single element. optional root which defaults to document (for shadow dom) */
8080
static getElement(els: GridStackElement, root: HTMLElement | Document = document): HTMLElement {
8181
if (typeof els === 'string') {
82-
const doc = ('getElementById' in (root || {})) ? root as Document : undefined;
82+
const doc = ('getElementById' in root) ? root as Document : undefined;
8383
if (!els.length) return null;
8484
if (doc && els[0] === '#') {
8585
return doc.getElementById(els.substring(1));
8686
}
8787
if (els[0] === '#' || els[0] === '.' || els[0] === '[') {
88-
return root?.querySelector(els);
88+
return root.querySelector(els);
8989
}
9090

9191
// if we start with a digit, assume it's an id (error calling querySelector('#1')) as class are not valid CSS
@@ -94,9 +94,9 @@ export class Utils {
9494
}
9595

9696
// finally try string, then id, then class
97-
let el = root?.querySelector(els)
97+
let el = root.querySelector(els);
9898
if (doc && !el) { el = doc.getElementById(els) }
99-
if (!el) { el = root?.querySelector('.' + els) }
99+
if (!el) { el = root.querySelector('.' + els) }
100100
return el as HTMLElement;
101101
}
102102
return els;

0 commit comments

Comments
 (0)