You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
checking the next code src/client.ts method updateTags
for(constattributeintag){if(Object.prototype.hasOwnProperty.call(tag,attribute)){if(attribute===TAG_PROPERTIES.INNER_HTML){newElement.innerHTML=tag.innerHTML;}elseif(attribute===TAG_PROPERTIES.CSS_TEXT){// This seems like a CSSImportRuleDeclaration?// @ts-ignoreif(newElement.styleSheet){// @ts-ignorenewElement.styleSheet.cssText=tag.cssText;}else{// @ts-ignorenewElement.appendChild(document.createTextNode(tag.cssText));}}else{constattr=attributeaskeyofHTMLElement;constvalue=typeoftag[attr]==='undefined' ? '' : tag[attr];newElement.setAttribute(attribute,valueasstring);}}}
if we notice, onload will be added with newElement.setAttribute that one is good for strings, but if we need to pass down onload or any other event should be a direct assignation for example
newElement['onload']=callback;// this way works and is not going to be rendered as string
in this way works perfectly, i havent make a PR due that probably you want to improve this code example
probably to keep linters happy i will pass the prop as onLoad and internally rename it to onload for javascript standards
in this way we can solve it
a proposal way for the fix
for(constattributeintag){if(Object.prototype.hasOwnProperty.call(tag,attribute)){if(attribute===TAG_PROPERTIES.INNER_HTML){newElement.innerHTML=tag.innerHTML;}elseif(attribute===TAG_PROPERTIES.CSS_TEXT){// This seems like a CSSImportRuleDeclaration?// @ts-ignoreif(newElement.styleSheet){// @ts-ignorenewElement.styleSheet.cssText=tag.cssText;}else{// @ts-ignorenewElement.appendChild(document.createTextNode(tag.cssText));}}elseif(typeoftag[attr]==='function'){// Events Here (example fix) will require more testsconstattr=attributeaskeyofHTMLElement;constvalue=typeoftag[attr]==='undefined' ? '' : tag[attr];newElement[attribute]=value;}else{constattr=attributeaskeyofHTMLElement;constvalue=typeoftag[attr]==='undefined' ? '' : tag[attr];newElement.setAttribute(attribute,valueasstring);}}}
The text was updated successfully, but these errors were encountered:
Hi @staylor , i was testing the library and the reason why onload is not working is because is getting rendered as string instead the reference,
https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute#value (check this one for references)
checking the next code
src/client.ts
methodupdateTags
if we notice,
onload
will be added withnewElement.setAttribute
that one is good for strings, but if we need to pass down onload or any other event should be a direct assignation for examplein this way works perfectly, i havent make a PR due that probably you want to improve this code example
with that change we can do things like this
probably to keep linters happy i will pass the prop as
onLoad
and internally rename it toonload
for javascript standardsin this way we can solve it
a proposal way for the fix
The text was updated successfully, but these errors were encountered: