Skip to content

Commit

Permalink
Allow textarea body
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Oct 8, 2024
1 parent 76d68cb commit f4cac4d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion datex-bindings/dom-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class DOMUtils {
html = html.trim();
template.innerHTML = html;
const element = <HTMLElement>template.content.firstChild;

if (content != undefined) {
// set html
if (Datex.ReactiveValue.collapseValue(content,true,true) instanceof this.context.HTMLElement) this.setElementHTML(element, <HTMLElement>content);
Expand Down Expand Up @@ -154,7 +155,7 @@ export class DOMUtils {
// unobserve?
this.element_bound_html_values.get(element)?.unobserve(element);
this.element_bound_text_values.get(element)?.unobserve(element);

// @ts-ignore markdown flag
element._use_markdown = markdown;

Expand All @@ -163,6 +164,7 @@ export class DOMUtils {

// Datexv Ref
else if (text instanceof Datex.ReactiveValue) {

this.updateElementText.call(element, text.val);

text.observe(this.updateElementText, element);
Expand Down Expand Up @@ -288,6 +290,15 @@ export class DOMUtils {
// use content if parent is <template>
const element = parent instanceof this.context.HTMLTemplateElement ? parent.content : parent;

// Handle HTMLTextAreaElement element body
if (element instanceof HTMLTextAreaElement) {
const reactiveProps = children.find(e => e instanceof Datex.ReactiveValue);
if (reactiveProps) {
this.setLiveAttribute(element, "value", reactiveProps);
return parent;
}
}

for (let child of children) {
child = (child as any)?.[JSX_INSERT_STRING] ? (child as any).val : child; // collapse safely injected strings

Expand Down

0 comments on commit f4cac4d

Please sign in to comment.