Open vans163 opened 5 years ago
@vans163 This is not currently possible. Only JSX within the script tags is supported. That being said, it is not impossible to implement. There would just need to be some conditional logic looking for an src
attribute and doing fetches to get the strings to process.
if(scripts.length===0) scripts = document.querySelectorAll("[type='text/jsx']");
scripts.forEach(el => { // change into a for of loop
// look for 'src' attribute, if found, fetch text content
// otherwise user innerHTML
const script = JSXTranspile(el.innerHTML,options),
node = document.createElement("script");
for(const attr of [].slice.call(el.attributes)) node.setAttribute(attr.name,el.attributes[attr.name]);
node.type = "text/javascript";
node.innerHTML = script;
el.parentElement.replaceChild(node,el);
});
This is cool yea, good to declutter the code a bit.
How do you load a script like ?