File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,17 @@ export function createOc(oc) {
106106 return href + ( ~ href . indexOf ( "?" ) ? "&" : "?" ) + $ . param ( parameters ) ;
107107 } ;
108108
109+ const reanimateScripts = ( component ) => {
110+ for ( const script of Array . from ( component . querySelectorAll ( "script" ) ) ) {
111+ const newScript = document . createElement ( "script" ) ;
112+ newScript . textContent = script . textContent ;
113+ for ( const attribute of Array . from ( script . attributes ) ) {
114+ newScript . setAttribute ( attribute . name , attribute . value ) ;
115+ }
116+ script . parentNode ?. replaceChild ( newScript , script ) ;
117+ }
118+ } ;
119+
109120 const getHeaders = ( ) => {
110121 const globalHeaders = ocConf . globalHeaders ;
111122 return {
@@ -198,6 +209,9 @@ export function createOc(oc) {
198209 setAttribute ( "data-version" , dataVersion ) ;
199210 setAttribute ( "data-id" , data . ocId ) ;
200211 component . innerHTML = data . html ;
212+ // If the html contains <scripts> tags, innerHTML will not execute them.
213+ // So we need to do it manually.
214+ reanimateScripts ( component ) ;
201215
202216 if ( data . key ) {
203217 setAttribute ( "data-hash" , data . key ) ;
You can’t perform that action at this time.
0 commit comments