jsuites 5.11.1 → 5.12.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.
Files changed (2) hide show
  1. package/dist/jsuites.js +27 -13
  2. package/package.json +1 -1
package/dist/jsuites.js CHANGED
@@ -427,14 +427,24 @@ Helpers.two = function(value) {
427
427
  }
428
428
 
429
429
  Helpers.focus = function(el) {
430
- if (el.innerText.length) {
431
- var range = document.createRange();
432
- var sel = window.getSelection();
433
- var node = el.childNodes[el.childNodes.length-1];
434
- range.setStart(node, node.length)
435
- range.collapse(true)
436
- sel.removeAllRanges()
437
- sel.addRange(range)
430
+ if (el.textContent.length) {
431
+ // Handle contenteditable elements
432
+ const range = document.createRange();
433
+ const sel = window.getSelection();
434
+
435
+ let node = el;
436
+ // Go as deep as possible to the last text node
437
+ while (node.lastChild) node = node.lastChild;
438
+ // Ensure it's a text node
439
+ if (node.nodeType === Node.TEXT_NODE) {
440
+ range.setStart(node, node.length);
441
+ } else {
442
+ range.setStart(node, node.childNodes.length);
443
+ }
444
+ range.collapse(true);
445
+ sel.removeAllRanges();
446
+ sel.addRange(range);
447
+
438
448
  el.scrollLeft = el.scrollWidth;
439
449
  }
440
450
  }
@@ -574,6 +584,10 @@ Helpers.findElement = function(element, condition) {
574
584
 
575
585
  /* harmony default export */ var helpers = (Helpers);
576
586
  ;// CONCATENATED MODULE: ./src/utils/path.js
587
+ const isValidPathObj = function(o) {
588
+ return typeof o === 'object' || typeof o === 'function';
589
+ }
590
+
577
591
  function Path(pathString, value, remove) {
578
592
  // Ensure the path is a valid, non-empty string
579
593
  if (typeof pathString !== 'string' || pathString.length === 0) {
@@ -597,7 +611,7 @@ function Path(pathString, value, remove) {
597
611
  // Check if the current object is valid and has the key
598
612
  if (
599
613
  currentObject != null &&
600
- typeof currentObject === 'object' &&
614
+ isValidPathObj(currentObject) &&
601
615
  Object.prototype.hasOwnProperty.call(currentObject, key)
602
616
  ) {
603
617
  currentObject = currentObject[key];
@@ -616,7 +630,7 @@ function Path(pathString, value, remove) {
616
630
  const key = keys[i];
617
631
 
618
632
  // Check if the current object is invalid (null/undefined or non-object)
619
- if (currentObject == null || typeof currentObject !== 'object') {
633
+ if (currentObject == null || ! isValidPathObj(currentObject)) {
620
634
  console.warn(`Cannot set value: path '${pathString}' blocked by invalid object at '${key}'`);
621
635
  return false;
622
636
  }
@@ -624,7 +638,7 @@ function Path(pathString, value, remove) {
624
638
  // If the key exists but is null/undefined or a non-object, replace it with an empty object
625
639
  if (
626
640
  Object.prototype.hasOwnProperty.call(currentObject, key) &&
627
- (currentObject[key] == null || typeof currentObject[key] !== 'object')
641
+ (currentObject[key] == null || ! isValidPathObj(currentObject[key]))
628
642
  ) {
629
643
  currentObject[key] = {};
630
644
  } else if (!Object.prototype.hasOwnProperty.call(currentObject, key)) {
@@ -640,7 +654,7 @@ function Path(pathString, value, remove) {
640
654
  const finalKey = keys[keys.length - 1];
641
655
 
642
656
  // Check if the current object is valid for setting/deleting
643
- if (currentObject == null || typeof currentObject !== 'object') {
657
+ if (currentObject == null || ! isValidPathObj(currentObject)) {
644
658
  return false;
645
659
  }
646
660
 
@@ -12996,7 +13010,7 @@ var jsuites_jSuites = {
12996
13010
  ...dictionary,
12997
13011
  ...helpers,
12998
13012
  /** Current version */
12999
- version: '5.11.0',
13013
+ version: '5.12.0',
13000
13014
  /** Bind new extensions to Jsuites */
13001
13015
  setExtensions: function(o) {
13002
13016
  if (typeof(o) == 'object') {
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "main": "dist/jsuites.js",
28
28
  "types": "dist/jsuites.d.ts",
29
- "version": "5.11.1",
29
+ "version": "5.12.0",
30
30
  "bugs": "https://github.com/jsuites/jsuites/issues",
31
31
  "homepage": "https://github.com/jsuites/jsuites",
32
32
  "docs": "https://jsuites.net",