@lvce-editor/renderer-process 30.22.2 → 30.23.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.
@@ -2386,6 +2386,17 @@ const createHiddenContainer = (activeElement, focused) => {
2386
2386
  }
2387
2387
  return $Hidden;
2388
2388
  };
2389
+ const updateAttributes = ($Previous, $New) => {
2390
+ const newAttributeNames = new Set($New.getAttributeNames());
2391
+ for (const attributeName of $Previous.getAttributeNames()) {
2392
+ if (!newAttributeNames.has(attributeName)) {
2393
+ $Previous.removeAttribute(attributeName);
2394
+ }
2395
+ }
2396
+ for (const attributeName of newAttributeNames) {
2397
+ $Previous.setAttribute(attributeName, $New.getAttribute(attributeName));
2398
+ }
2399
+ };
2389
2400
  const restoreFocusedElement = ($Hidden, $New, focused) => {
2390
2401
  const $NewFocused = $New.querySelector(`[name="${CSS.escape(focused)}"]`);
2391
2402
  if (!$NewFocused) {
@@ -2395,8 +2406,7 @@ const restoreFocusedElement = ($Hidden, $New, focused) => {
2395
2406
  if (!$Previous) {
2396
2407
  return;
2397
2408
  }
2398
- $Previous.className = $NewFocused.className;
2399
- $Previous.placeholder = $NewFocused.placeholder;
2409
+ updateAttributes($Previous, $NewFocused);
2400
2410
  if ($NewFocused.childNodes) {
2401
2411
  $Previous.replaceChildren(...$NewFocused.childNodes);
2402
2412
  }
@@ -2440,31 +2450,34 @@ const restoreFocus = ($Viewlet, isRootTree, isTreeFocused, focused) => {
2440
2450
  };
2441
2451
  const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
2442
2452
  startIgnore();
2443
- const oldLeft = $Viewlet.style.left;
2444
- const oldTop = $Viewlet.style.top;
2445
- const oldWidth = $Viewlet.style.width;
2446
- const oldHeight = $Viewlet.style.height;
2447
- const activeElement = getActiveElementInside($Viewlet);
2448
- const isTreeFocused = activeElement?.getAttribute('role') === 'tree';
2449
- const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
2450
- const focused = activeElement?.getAttribute('name') || null;
2451
- const $Hidden = createHiddenContainer(activeElement, focused);
2452
- if (uid) {
2453
- const numericUid = Number(uid);
2454
- const inputMap = getInputMap($Viewlet);
2455
- $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
2456
- }
2457
- if (!uid) {
2458
- renderInto($Viewlet, dom, eventMap);
2459
- }
2460
- $Hidden.remove();
2461
- restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
2462
- $Viewlet.style.top = oldTop;
2463
- $Viewlet.style.left = oldLeft;
2464
- $Viewlet.style.height = oldHeight;
2465
- $Viewlet.style.width = oldWidth;
2466
- stopIgnore();
2467
- return $Viewlet;
2453
+ try {
2454
+ const oldLeft = $Viewlet.style.left;
2455
+ const oldTop = $Viewlet.style.top;
2456
+ const oldWidth = $Viewlet.style.width;
2457
+ const oldHeight = $Viewlet.style.height;
2458
+ const activeElement = getActiveElementInside($Viewlet);
2459
+ const isTreeFocused = activeElement?.getAttribute('role') === 'tree';
2460
+ const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
2461
+ const focused = activeElement?.getAttribute('name') || null;
2462
+ const $Hidden = createHiddenContainer(activeElement, focused);
2463
+ if (uid) {
2464
+ const numericUid = Number(uid);
2465
+ const inputMap = getInputMap($Viewlet);
2466
+ $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
2467
+ }
2468
+ if (!uid) {
2469
+ renderInto($Viewlet, dom, eventMap);
2470
+ }
2471
+ $Hidden.remove();
2472
+ restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
2473
+ $Viewlet.style.top = oldTop;
2474
+ $Viewlet.style.left = oldLeft;
2475
+ $Viewlet.style.height = oldHeight;
2476
+ $Viewlet.style.width = oldWidth;
2477
+ return $Viewlet;
2478
+ } finally {
2479
+ stopIgnore();
2480
+ }
2468
2481
  };
2469
2482
 
2470
2483
  const state = {
@@ -1540,6 +1540,17 @@ const createHiddenContainer = (activeElement, focused) => {
1540
1540
  }
1541
1541
  return $Hidden;
1542
1542
  };
1543
+ const updateAttributes = ($Previous, $New) => {
1544
+ const newAttributeNames = new Set($New.getAttributeNames());
1545
+ for (const attributeName of $Previous.getAttributeNames()) {
1546
+ if (!newAttributeNames.has(attributeName)) {
1547
+ $Previous.removeAttribute(attributeName);
1548
+ }
1549
+ }
1550
+ for (const attributeName of newAttributeNames) {
1551
+ $Previous.setAttribute(attributeName, $New.getAttribute(attributeName));
1552
+ }
1553
+ };
1543
1554
  const restoreFocusedElement = ($Hidden, $New, focused) => {
1544
1555
  const $NewFocused = $New.querySelector(`[name="${CSS.escape(focused)}"]`);
1545
1556
  if (!$NewFocused) {
@@ -1549,8 +1560,7 @@ const restoreFocusedElement = ($Hidden, $New, focused) => {
1549
1560
  if (!$Previous) {
1550
1561
  return;
1551
1562
  }
1552
- $Previous.className = $NewFocused.className;
1553
- $Previous.placeholder = $NewFocused.placeholder;
1563
+ updateAttributes($Previous, $NewFocused);
1554
1564
  if ($NewFocused.childNodes) {
1555
1565
  $Previous.replaceChildren(...$NewFocused.childNodes);
1556
1566
  }
@@ -1594,31 +1604,34 @@ const restoreFocus = ($Viewlet, isRootTree, isTreeFocused, focused) => {
1594
1604
  };
1595
1605
  const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1596
1606
  startIgnore();
1597
- const oldLeft = $Viewlet.style.left;
1598
- const oldTop = $Viewlet.style.top;
1599
- const oldWidth = $Viewlet.style.width;
1600
- const oldHeight = $Viewlet.style.height;
1601
- const activeElement = getActiveElementInside($Viewlet);
1602
- const isTreeFocused = activeElement?.getAttribute('role') === 'tree';
1603
- const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
1604
- const focused = activeElement?.getAttribute('name') || null;
1605
- const $Hidden = createHiddenContainer(activeElement, focused);
1606
- if (uid) {
1607
- const numericUid = Number(uid);
1608
- const inputMap = getInputMap($Viewlet);
1609
- $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
1610
- }
1611
- if (!uid) {
1612
- renderInto($Viewlet, dom, eventMap);
1613
- }
1614
- $Hidden.remove();
1615
- restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
1616
- $Viewlet.style.top = oldTop;
1617
- $Viewlet.style.left = oldLeft;
1618
- $Viewlet.style.height = oldHeight;
1619
- $Viewlet.style.width = oldWidth;
1620
- stopIgnore();
1621
- return $Viewlet;
1607
+ try {
1608
+ const oldLeft = $Viewlet.style.left;
1609
+ const oldTop = $Viewlet.style.top;
1610
+ const oldWidth = $Viewlet.style.width;
1611
+ const oldHeight = $Viewlet.style.height;
1612
+ const activeElement = getActiveElementInside($Viewlet);
1613
+ const isTreeFocused = activeElement?.getAttribute('role') === 'tree';
1614
+ const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
1615
+ const focused = activeElement?.getAttribute('name') || null;
1616
+ const $Hidden = createHiddenContainer(activeElement, focused);
1617
+ if (uid) {
1618
+ const numericUid = Number(uid);
1619
+ const inputMap = getInputMap($Viewlet);
1620
+ $Viewlet = renderWithUid($Viewlet, dom, eventMap, numericUid, inputMap, focused, $Hidden);
1621
+ }
1622
+ if (!uid) {
1623
+ renderInto($Viewlet, dom, eventMap);
1624
+ }
1625
+ $Hidden.remove();
1626
+ restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
1627
+ $Viewlet.style.top = oldTop;
1628
+ $Viewlet.style.left = oldLeft;
1629
+ $Viewlet.style.height = oldHeight;
1630
+ $Viewlet.style.width = oldWidth;
1631
+ return $Viewlet;
1632
+ } finally {
1633
+ stopIgnore();
1634
+ }
1622
1635
  };
1623
1636
 
1624
1637
  const get$6 = ids => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.22.2",
3
+ "version": "30.23.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"