container.js 554 B

12345678910111213141516171819202122
  1. const container = (name, customisation = null) => {
  2. if (typeof(name) !== "string") {
  3. throw new TypeError("Name of the container must be string.");
  4. }
  5. if (customisation !== null && typeof(customisation) !== "function") {
  6. throw new TypeError("Customisation must be null or function.");
  7. }
  8. const target = document.createElement("div");
  9. target.classList.add("container");
  10. target.id = "container-" + name;
  11. if (customisation) {
  12. customisation(target);
  13. }
  14. return target;
  15. };
  16. export { container };