@lvce-editor/virtual-dom 7.4.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
@@ -66,6 +66,7 @@ const Html$1 = 'html';
66
66
  const Head$1 = 'head';
67
67
  const Title$1 = 'title';
68
68
  const Meta$1 = 'meta';
69
+ const Canvas$1 = 'canvas';
69
70
 
70
71
  const Audio$1 = 0;
71
72
  const Button$1 = 1;
@@ -130,6 +131,7 @@ const Html = 73;
130
131
  const Head = 74;
131
132
  const Title = 75;
132
133
  const Meta = 76;
134
+ const Canvas = 77;
133
135
  const Reference$1 = 100;
134
136
 
135
137
  const VirtualDomElements$1 = {
@@ -141,6 +143,7 @@ const VirtualDomElements$1 = {
141
143
  Audio: Audio$1,
142
144
  Br: Br$1,
143
145
  Button: Button$1,
146
+ Canvas,
144
147
  Cite: Cite$1,
145
148
  Code: Code$1,
146
149
  Col: Col$1,
@@ -214,6 +217,8 @@ const getElementTag$1 = type => {
214
217
  return Br$2;
215
218
  case Button$1:
216
219
  return Button$2;
220
+ case Canvas:
221
+ return Canvas$1;
217
222
  case Cite$1:
218
223
  return Cite$2;
219
224
  case Code$1:
@@ -467,6 +472,22 @@ const attachEvent = ($Node, eventMap, key, value, newEventMap) => {
467
472
  $Node.addEventListener(keyLower, wrapped, options);
468
473
  };
469
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
+
470
491
  const setProp = ($Element, key, value, eventMap, newEventMap) => {
471
492
  switch (key) {
472
493
  case 'ariaActivedescendant':
@@ -490,6 +511,9 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
490
511
  $Element.removeAttribute('aria-owns');
491
512
  }
492
513
  break;
514
+ case 'childCount':
515
+ case 'type':
516
+ break;
493
517
  case 'height':
494
518
  case 'width':
495
519
  if ($Element instanceof HTMLImageElement) {
@@ -555,9 +579,7 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
555
579
  attachEvent($Element, eventMap, eventName, value, newEventMap);
556
580
  break;
557
581
  case 'style':
558
- throw new Error('style property is not supported');
559
- case 'childCount':
560
- case 'type':
582
+ setStyle($Element, value);
561
583
  break;
562
584
  case 'translate':
563
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.4.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"