MCPcopy
hub / github.com/autoNumeric/autoNumeric / text

Method text

src/AutoNumericHelper.js:1371–1387  ·  view source on GitHub ↗

* Return the text component of the given DOM element. * * @param {Element} domElement * @returns {string}

(domElement)

Source from the content-addressed store, hash-verified

1369 * @returns {string}
1370 */
1371 static text(domElement) {
1372 const nodeType = domElement.nodeType;
1373
1374 let result;
1375 // cf. https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
1376 if (nodeType === Node.ELEMENT_NODE ||
1377 nodeType === Node.DOCUMENT_NODE ||
1378 nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1379 result = domElement.textContent;
1380 } else if (nodeType === Node.TEXT_NODE) {
1381 result = domElement.nodeValue;
1382 } else {
1383 result = '';
1384 }
1385
1386 return result;
1387 }
1388
1389 /**
1390 * Set the text content of the given DOM element.

Callers 1

getElementValueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected