chirashijs/chirashi

View on GitHub
lib/dom/getHtml.js

Summary

Maintainability
A
0 mins
Test Coverage
import getProp from './getProp'

/**
 * Get the inner html of an element.
 * @param {(string|Array|NodeList|HTMLCollection|Element)} element - The element. Note that it'll be passed to getElement to ensure there's only one.
 * @return {(string|null)} innerHTML - The inner html of the element or null if no element found.
 * @example //esnext
 * import { createElement, setHtml, getHtml } from 'chirashi'
 * const maki = createElement('p.maki')
 * setHtml(maki, 'salmon')
 * getHtml(maki) //returns: "salmon"
 * @example //es5
 * var maki = createElement('p.maki')
 * setHtml(maki, 'salmon')
 * getHtml(maki) //returns: "salmon"
 */
export default function getHtml (element) {
  return getProp(element, 'innerHTML')
}