view.js 720 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { abstract } from "assets/abstract.js";
  2. import { types } from "assets/types.js";
  3. class view {
  4. #app;
  5. #name;
  6. constructor(app, name = undefined) {
  7. types.check_html_element(app);
  8. types.check_string(name, true);
  9. this.#app = app;
  10. this.#name = name;
  11. }
  12. get has_name() {
  13. return this.#name !== undefined && this.#name !== null;
  14. }
  15. get name() {
  16. return this.#name;
  17. }
  18. get app() {
  19. return this.#app;
  20. }
  21. _clean() {
  22. while (this.app.hasChildNodes()) {
  23. this.app.firstChild.remove();
  24. }
  25. }
  26. hide() {
  27. this._clean();
  28. }
  29. show() {
  30. throw abstract();
  31. }
  32. }
  33. export { view };