MCPcopy
hub / github.com/toorshia/justgage / attr

Method attr

src/rendering/svg.js:524–580  ·  view source on GitHub ↗

* Set element attributes

(attrs)

Source from the content-addressed store, hash-verified

522 * Set element attributes
523 */
524 attr(attrs) {
525 if (typeof attrs === 'string') {
526 return this.element.getAttribute(attrs);
527 }
528
529 Object.keys(attrs).forEach(key => {
530 const value = attrs[key];
531
532 // Handle special attribute mappings
533 switch (key) {
534 case 'text':
535 // For SVG text elements, set textContent instead of attribute
536 this.element.textContent = value;
537 break;
538 case 'fill':
539 this.element.setAttribute('fill', value);
540 break;
541 case 'stroke':
542 this.element.setAttribute('stroke', value);
543 break;
544 case 'stroke-width':
545 case 'strokeWidth':
546 this.element.setAttribute('stroke-width', value);
547 break;
548 case 'opacity':
549 this.element.setAttribute('opacity', value);
550 break;
551 case 'font-family':
552 case 'fontFamily':
553 this.element.setAttribute('font-family', value);
554 break;
555 case 'font-size':
556 case 'fontSize':
557 this.element.setAttribute('font-size', value);
558 break;
559 case 'font-weight':
560 case 'fontWeight':
561 this.element.setAttribute('font-weight', value);
562 break;
563 case 'text-anchor':
564 case 'textAnchor':
565 this.element.setAttribute('text-anchor', value);
566 break;
567 case 'dominant-baseline':
568 case 'dominantBaseline':
569 this.element.setAttribute('dominant-baseline', value);
570 break;
571 case 'filter':
572 this.element.setAttribute('filter', value);
573 break;
574 default:
575 this.element.setAttribute(key, value);
576 }
577 });
578
579 return this;
580 }
581

Callers 15

_drawGaugeMethod · 0.80
_drawLevelMethod · 0.80
_drawSectorColorsMethod · 0.80
_drawLabelsMethod · 0.80
_drawPointerMethod · 0.80
_drawTargetLineMethod · 0.80
refreshMethod · 0.80
_updatePropertyMethod · 0.80
_updateCounterTextMethod · 0.80
applyShadowToElementsMethod · 0.80
svg.test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected