@lvce-editor/virtual-dom 7.5.0 → 8.0.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.
package/dist/index.js CHANGED
@@ -472,6 +472,22 @@ const attachEvent = ($Node, eventMap, key, value, newEventMap) => {
472
472
  $Node.addEventListener(keyLower, wrapped, options);
473
473
  };
474
474
 
475
+ const STYLE_REGEX = /([^:;]+):\s*([^;]+)/g;
476
+ const KEBAB_CASE_REGEX = /-([a-z])/g;
477
+ const setStyle = ($Element, styleString) => {
478
+ if (typeof styleString !== 'string') {
479
+ return;
480
+ }
481
+ let match;
482
+ while ((match = STYLE_REGEX.exec(styleString)) !== null) {
483
+ const key = match[1].trim();
484
+ const value = match[2].trim();
485
+ // Convert kebab-case to camelCase for CSS properties with dashes
486
+ const camelCaseKey = key.replaceAll(KEBAB_CASE_REGEX, (_, char) => char.toUpperCase());
487
+ $Element.style[camelCaseKey] = value;
488
+ }
489
+ };
490
+
475
491
  const setProp = ($Element, key, value, eventMap, newEventMap) => {
476
492
  switch (key) {
477
493
  case 'ariaActivedescendant':
@@ -495,6 +511,9 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
495
511
  $Element.removeAttribute('aria-owns');
496
512
  }
497
513
  break;
514
+ case 'childCount':
515
+ case 'type':
516
+ break;
498
517
  case 'height':
499
518
  case 'width':
500
519
  if ($Element instanceof HTMLImageElement) {
@@ -560,9 +579,7 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
560
579
  attachEvent($Element, eventMap, eventName, value, newEventMap);
561
580
  break;
562
581
  case 'style':
563
- throw new Error('style property is not supported');
564
- case 'childCount':
565
- case 'type':
582
+ setStyle($Element, value);
566
583
  break;
567
584
  case 'translate':
568
585
  $Element.style[key] = value;
@@ -0,0 +1 @@
1
+ export declare const setStyle: ($Element: HTMLElement, styleString: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "7.5.0",
3
+ "version": "8.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"