MCPcopy Index your code
hub / github.com/microsoft/SandDance / text

Function text

docs/app/js/sanddance-app.js:124491–124527  ·  view source on GitHub ↗
(mdef, el, item)

Source from the content-addressed store, hash-verified

124489 } else setStyle(el, "image-rendering", null);
124490 },
124491 text (mdef, el, item) {
124492 const tl6 = textLines(item);
124493 let key, value11, doc, lh;
124494 if ((0, _vegaUtil.isArray)(tl6)) {
124495 // multi-line text
124496 value11 = tl6.map((_)=>textValue(item, _));
124497 key = value11.join("\n"); // content cache key
124498 if (key !== values.text) {
124499 domClear(el, 0);
124500 doc = el.ownerDocument;
124501 lh = lineHeight(item);
124502 value11.forEach((t, i)=>{
124503 const ts1 = domCreate(doc, "tspan", svgns);
124504 ts1.__data__ = item; // data binding
124505 ts1.textContent = t;
124506 if (i) {
124507 ts1.setAttribute("x", 0);
124508 ts1.setAttribute("dy", lh);
124509 }
124510 el.appendChild(ts1);
124511 });
124512 values.text = key;
124513 }
124514 } else {
124515 // single-line text
124516 value11 = textValue(item, tl6);
124517 if (value11 !== values.text) {
124518 el.textContent = value11;
124519 values.text = value11;
124520 }
124521 }
124522 setAttribute(el, "font-family", fontFamily(item));
124523 setAttribute(el, "font-size", fontSize(item) + "px");
124524 setAttribute(el, "font-style", item.fontStyle);
124525 setAttribute(el, "font-variant", item.fontVariant);
124526 setAttribute(el, "font-weight", item.fontWeight);
124527 }
124528};
124529function emit(name, value12, ns) {
124530 // early exit if value is unchanged

Callers 1

cloudFunction · 0.70

Calls 9

textLinesFunction · 0.70
textValueFunction · 0.70
domClearFunction · 0.70
lineHeightFunction · 0.70
domCreateFunction · 0.70
setAttributeFunction · 0.70
fontFamilyFunction · 0.70
fontSizeFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected