In case someone runs into the same issue, I've attached a patch to
remove the temporary div.
In short this snippet moves the content after the div and then removes
the div. Not sure if this will have nasty side effects though.
regards
bob
Index: jquery.taconite.js
--- jquery.taconite.js Base (BASE)
+++ jquery.taconite.js Locally Modified (Based On LOCAL)
@@ -150,6 +150,7 @@
continue;
}
var cdataWrap = cmdNode.getAttribute('cdataWrap') ||
$.taconite.defaults.cdataWrap;
+ var unwrap = [];
var a = [];
if (cmdNode.childNodes.length > 0) {
@@ -178,7 +179,13 @@
log("invoking command: $('", q, "').", cmd, '('+ arg
+')');
}
jq[cmd].apply(jq,a);
+
+ // Unwrap cdataWrap element contents
+ while (el = unwrap.shift()) {
+ var jel = $(el);
+ jel.after(jel.html()).remove();
}
+ }
// apply dynamic fixes
if (doPostProcess)
postProcess();
@@ -217,6 +224,8 @@
function handleCDATA(s) {
var el = document.createElement(cdataWrap);
+ // Add cdataWrap element, to be unwrapped later
+ unwrap.push(el);
el.innerHTML = s;
return el;
};
Bob Schellink wrote:
Hi Mike,
Thanks for your feedback. Your solution does work in the scenario I
described where only one link is used. However it is possible to return
multiple elements for example:
<taconite>
<append>
<a href="...">hello</a>
<a href="...">hi</a>
</append>
</taconite>
To provide some context, I am integrating taconite into a component
framework and do not have much control over the commands and their content.
Hmm would it work to "unwrap" (does that even make sense) the div contents?
kind regards
bob
Mike Alsup wrote:
In order to do this taconite places the CDATA content inside a div
element. However after the command is executed the div is left in the
DOM.
So after a bit of back and forth between browser and server we end up
with a large hierarchy of divs.
Hi Bob,
Could you test this function to see if it fixes the issue for you?
(just replace the current one in Taconite)
function handleCDATA(s) {
var el = document.createElement(cdataWrap);
el.innerHTML = s;
// remove wrapper node if possible
var $el = $(el), $ch = $el.children();
if ($ch.size() == 1)
return $ch[0];
return el;
};
Thanks.
Mike