File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/scramjet/src/client/dom Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -418,6 +418,37 @@ export default function (client: ScramjetClient, self: typeof window) {
418418 } catch { }
419419 } ,
420420 } ) ;
421+
422+ // TODO: this needs to be done for all insert methods
423+ client . Proxy ( [ "Element.prototype.appendChild" , "Element.prototype.append" ] , {
424+ apply ( ctx ) {
425+ if ( ctx . this instanceof self . HTMLStyleElement ) {
426+ for ( const node of ctx . args ) {
427+ if ( node instanceof self . Text ) {
428+ node . data = rewriteCss ( ctx . args [ 0 ] . data , client . meta ) ;
429+ }
430+ }
431+ } else if ( ctx . this instanceof self . HTMLScriptElement ) {
432+ for ( const node of ctx . args ) {
433+ if ( node instanceof self . Text ) {
434+ const newval : string = rewriteJs (
435+ node . data ,
436+ "(anonymous script element)" ,
437+ client . meta
438+ ) as string ;
439+ client . natives . call (
440+ "Element.prototype.setAttribute" ,
441+ ctx . this ,
442+ "scramjet-attr-script-source-src" ,
443+ bytesToBase64 ( encoder . encode ( newval ) )
444+ ) ;
445+ node . data = newval ;
446+ }
447+ }
448+ }
449+ } ,
450+ } ) ;
451+
421452 client . Proxy ( "Audio" , {
422453 construct ( ctx ) {
423454 if ( ctx . args [ 0 ] ) ctx . args [ 0 ] = rewriteUrl ( ctx . args [ 0 ] , client . meta ) ;
You can’t perform that action at this time.
0 commit comments