diff --git a/src/template/example.html b/src/template/example.html index 9ebc2ec..d97082d 100644 --- a/src/template/example.html +++ b/src/template/example.html @@ -10,6 +10,13 @@

$textinterp

Oh, look: a normal dollar sign: $. And then a dollar sign with no vars (does not resolve, emits error): $dollar

+ +
@@ -40,6 +47,7 @@ }, title: `A title, injected`, dynamicInterp: document.getElementById(`text-interp`).value, + selectval: `three`, }); document.getElementById(`template-add`).appendChild(bind); }; diff --git a/src/template/template-e6d.js b/src/template/template-e6d.js index bbbee4f..50764d2 100644 --- a/src/template/template-e6d.js +++ b/src/template/template-e6d.js @@ -67,10 +67,16 @@ class TemplateE6d extends HTMLTemplateElement { } else { const textTemplate = buildTextTemplate(node.getAttribute(attr)); if (textTemplate) { - bindAttr.push({ + const bindLogic = { attr: attr, template: textTemplate, - }); + }; + if (node.nodeName === `SELECT` && attr === `data-e6d-value`) { + bindLogic.func = (el, val) => { + el.value = val; + }; + } + bindAttr.push(bindLogic); } } } @@ -160,7 +166,12 @@ class TemplateE6d extends HTMLTemplateElement { const injectTarget = resolve(templated, route.route); for (const attr of route.bind.attr) { const attrValue = templateString(attr.template, obj); - injectTarget.setAttribute(attr.attr, attrValue); + if (attr.func) { + attr.func(injectTarget, attrValue); + injectTarget.removeAttribute(attr.attr); + } else if (attr.template) { + injectTarget.setAttribute(attr.attr, attrValue); + } } for (const evt of route.bind.event) { const trigger = evt.event;