mol_plot_all 1.2.1335 → 1.2.1337

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.
package/web.js CHANGED
@@ -1570,9 +1570,16 @@ var $;
1570
1570
  static focused(next, notify) {
1571
1571
  const parents = [];
1572
1572
  let element = next?.[0] ?? $mol_dom_context.document.activeElement;
1573
+ while (element?.shadowRoot) {
1574
+ element = element.shadowRoot.activeElement;
1575
+ }
1573
1576
  while (element) {
1574
1577
  parents.push(element);
1575
- element = element.parentNode;
1578
+ const parent = element.parentNode;
1579
+ if (parent instanceof ShadowRoot)
1580
+ element = parent.host;
1581
+ else
1582
+ element = parent;
1576
1583
  }
1577
1584
  if (!next || notify)
1578
1585
  return parents;
@@ -1607,9 +1614,17 @@ var $;
1607
1614
  var $;
1608
1615
  (function ($) {
1609
1616
  if ($mol_dom_context.document) {
1610
- $mol_dom_context.document.documentElement.addEventListener('focus', (event) => {
1611
- $mol_view_selection.focused($mol_maybe($mol_dom_context.document.activeElement), 'notify');
1612
- }, true);
1617
+ function focus(event) {
1618
+ const target = event.target;
1619
+ if (target?.shadowRoot)
1620
+ watch(target.shadowRoot);
1621
+ $mol_view_selection.focused($mol_maybe(target), 'notify');
1622
+ }
1623
+ function watch(root) {
1624
+ root.removeEventListener('focus', focus, true);
1625
+ root.addEventListener('focus', focus, true);
1626
+ }
1627
+ watch($mol_dom_context.document);
1613
1628
  }
1614
1629
  })($ || ($ = {}));
1615
1630