image.js 798 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { types } from "assets/types.js";
  2. import { widget } from "interface/widget.js";
  3. class image extends widget {
  4. constructor(source, description, name = undefined) {
  5. types.check_string(source);
  6. types.check_string(description, true);
  7. if (description === undefined && description === null) {
  8. description = "";
  9. }
  10. const target = document.createElement("img");
  11. target.src = source;
  12. target.alt = description;
  13. super(target, "image", name);
  14. }
  15. set source(target) {
  16. this._content = target;
  17. }
  18. set description(target) {
  19. types.check_string(target, true);
  20. if (target === undefined) {
  21. target = "";
  22. }
  23. this.node.alt = target;
  24. }
  25. }
  26. export { image };