JustHTML.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright (C) 2024 Puter Technologies Inc.
  3. *
  4. * This file is part of Puter.
  5. *
  6. * Puter is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. const Component = use('util.Component');
  20. /**
  21. * Allows using an HTML string as a component.
  22. */
  23. export default def(class JustHTML extends Component {
  24. static ID = 'ui.component.JustHTML';
  25. static PROPERTIES = { html: { value: '' } };
  26. create_template ({ template }) {
  27. $(template).html(H`<span></span>`);
  28. }
  29. on_ready ({ listen }) {
  30. listen('html', html => {
  31. $(this.dom_).find('span').html(html);
  32. });
  33. }
  34. _set_dom_based_on_render_mode({ property_values }) {
  35. if ( property_values.no_shadow ) {
  36. this.dom_ = this;
  37. return;
  38. }
  39. return super._set_dom_based_on_render_mode();
  40. }
  41. });