@tylertech/forge-core 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -166,17 +166,22 @@ export class RangeMediaObserver extends MediaObserver {
166
166
  if (!this._isInitialized) {
167
167
  return;
168
168
  }
169
- if (value.matches) {
170
- this._valueQueue.push(name);
171
- }
172
169
  if (!this._isAwaitingQueries) {
173
170
  setTimeout(() => {
174
171
  this.next([...this._valueQueue]);
175
172
  this._valueQueue = [];
176
173
  this._isAwaitingQueries = false;
177
174
  });
175
+ this._valueQueue = [...this.source];
178
176
  this._isAwaitingQueries = true;
179
177
  }
178
+ const index = this._valueQueue.findIndex(queued => queued === name);
179
+ if (value.matches && index === -1) {
180
+ this._valueQueue.push(name);
181
+ }
182
+ else if (!value.matches && index > -1) {
183
+ this._valueQueue.splice(index, 1);
184
+ }
180
185
  }
181
186
  }
182
187
  /**
@@ -637,11 +637,12 @@ export function deepQuerySelectorAll(rootElement, selectors, checkRootElement =
637
637
  }
638
638
  /**
639
639
  * Gets the currently focused element within the document by also traversing shadow roots.
640
+ * @param {Document} doc The document to get the active element from. Defaults to the current document.
640
641
  * @returns {Element}
641
642
  */
642
- export function getActiveElement() {
643
- const activeElement = document.activeElement;
644
- if (!activeElement || activeElement === document.body) {
643
+ export function getActiveElement(doc = document) {
644
+ const activeElement = doc.activeElement;
645
+ if (!activeElement || activeElement === doc.body) {
645
646
  return activeElement;
646
647
  }
647
648
  return getActiveShadowElement(activeElement);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tylertech/forge-core",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "A library of core web utilities that support Forge Web Component libraries.",
5
5
  "author": "Tyler Technologies, Inc.",
6
6
  "license": "Apache-2.0",
@@ -211,9 +211,10 @@ export declare function matchesSelectors(el: Element | Node, selectors: string |
211
211
  export declare function deepQuerySelectorAll(rootElement: Element, selectors: string | string[], checkRootElement?: boolean): Element[];
212
212
  /**
213
213
  * Gets the currently focused element within the document by also traversing shadow roots.
214
+ * @param {Document} doc The document to get the active element from. Defaults to the current document.
214
215
  * @returns {Element}
215
216
  */
216
- export declare function getActiveElement(): Element;
217
+ export declare function getActiveElement(doc?: Document): Element;
217
218
  /**
218
219
  * Gets the active element within the provided elements shadow root. If the element
219
220
  * does not have a shadow root, the provided element is returned.