@unsetsoft/ryunixjs 1.2.4-canary.4 → 1.2.4-canary.5
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/Ryunix.esm.js +43 -3
- package/dist/Ryunix.esm.js.map +1 -1
- package/dist/Ryunix.umd.js +43 -3
- package/dist/Ryunix.umd.js.map +1 -1
- package/dist/Ryunix.umd.min.js +1 -1
- package/dist/Ryunix.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/Ryunix.esm.js
CHANGED
|
@@ -355,7 +355,15 @@ const createDom = (fiber) => {
|
|
|
355
355
|
if (fiber.type === RYUNIX_TYPES.TEXT_ELEMENT) {
|
|
356
356
|
dom = document.createTextNode('');
|
|
357
357
|
} else if (is.string(fiber.type)) {
|
|
358
|
-
|
|
358
|
+
const isSvg = [
|
|
359
|
+
'svg', 'path', 'g', 'circle', 'polygon', 'rect', 'line', 'polyline', 'ellipse', 'text', 'tspan'
|
|
360
|
+
].includes(fiber.type);
|
|
361
|
+
|
|
362
|
+
if (isSvg) {
|
|
363
|
+
dom = document.createElementNS('http://www.w3.org/2000/svg', fiber.type);
|
|
364
|
+
} else {
|
|
365
|
+
dom = document.createElement(fiber.type);
|
|
366
|
+
}
|
|
359
367
|
} else {
|
|
360
368
|
if (process.env.NODE_ENV !== 'production') {
|
|
361
369
|
console.warn(
|
|
@@ -414,7 +422,20 @@ const updateDom = (dom, prevProps = {}, nextProps = {}) => {
|
|
|
414
422
|
) {
|
|
415
423
|
return
|
|
416
424
|
}
|
|
417
|
-
dom
|
|
425
|
+
if (dom instanceof SVGElement) {
|
|
426
|
+
let attrName = name;
|
|
427
|
+
if (name === 'strokeWidth') attrName = 'stroke-width';
|
|
428
|
+
if (name === 'strokeLinecap') attrName = 'stroke-linecap';
|
|
429
|
+
if (name === 'strokeLinejoin') attrName = 'stroke-linejoin';
|
|
430
|
+
if (name === 'strokeDasharray') attrName = 'stroke-dasharray';
|
|
431
|
+
if (name === 'strokeDashoffset') attrName = 'stroke-dashoffset';
|
|
432
|
+
if (name === 'fillRule') attrName = 'fill-rule';
|
|
433
|
+
if (name === 'clipRule') attrName = 'clip-rule';
|
|
434
|
+
dom.removeAttribute(attrName);
|
|
435
|
+
} else {
|
|
436
|
+
dom[name] = '';
|
|
437
|
+
dom.removeAttribute(name);
|
|
438
|
+
}
|
|
418
439
|
});
|
|
419
440
|
|
|
420
441
|
// Set new properties
|
|
@@ -450,7 +471,26 @@ const updateDom = (dom, prevProps = {}, nextProps = {}) => {
|
|
|
450
471
|
dom[name] = nextProps[name];
|
|
451
472
|
}
|
|
452
473
|
} else {
|
|
453
|
-
|
|
474
|
+
const isSvgNode = dom instanceof SVGElement;
|
|
475
|
+
// Camel case to true attribute map (e.g. strokeWidth -> stroke-width)
|
|
476
|
+
let attrName = name;
|
|
477
|
+
if (isSvgNode) {
|
|
478
|
+
if (name === 'strokeWidth') attrName = 'stroke-width';
|
|
479
|
+
if (name === 'strokeLinecap') attrName = 'stroke-linecap';
|
|
480
|
+
if (name === 'strokeLinejoin') attrName = 'stroke-linejoin';
|
|
481
|
+
if (name === 'strokeDasharray') attrName = 'stroke-dasharray';
|
|
482
|
+
if (name === 'strokeDashoffset') attrName = 'stroke-dashoffset';
|
|
483
|
+
if (name === 'fillRule') attrName = 'fill-rule';
|
|
484
|
+
if (name === 'clipRule') attrName = 'clip-rule';
|
|
485
|
+
// viewBox is case sensitive, we respect the camelCase for it.
|
|
486
|
+
dom.setAttribute(attrName, nextProps[name]);
|
|
487
|
+
} else {
|
|
488
|
+
dom[name] = nextProps[name];
|
|
489
|
+
// Best effort: set html attributes if it's not a primitive component property
|
|
490
|
+
if (typeof nextProps[name] !== 'object' && typeof nextProps[name] !== 'function') {
|
|
491
|
+
dom.setAttribute(name, nextProps[name]);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
454
494
|
}
|
|
455
495
|
}
|
|
456
496
|
} catch (error) {
|