8
0

getdatafromelement.js 576 B

123456789101112131415161718192021222324
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals HTMLTextAreaElement */
  6. /**
  7. * @module utils/dom/getdatafromelement
  8. */
  9. /**
  10. * Gets data from a given source element.
  11. *
  12. * @param {HTMLElement} el The element from which the data will be retrieved.
  13. * @returns {String} The data string.
  14. */
  15. export default function getDataFromElement( el ) {
  16. if ( el instanceof HTMLTextAreaElement ) {
  17. return el.value;
  18. }
  19. return el.innerHTML;
  20. }