File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -420,27 +420,20 @@ async function onApiLoaded() {
420420 }
421421}
422422
423- /**
424- * Original still using ES5, so we need to define custom elements using ES5 style
425- */
426423const definePearTransElements = ( ) => {
427- const PearTrans = function ( ) { } ;
428- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
429- PearTrans . prototype = Object . create ( HTMLElement . prototype ) ;
430- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
431- PearTrans . prototype . connectedCallback = function ( ) {
432- const that = this as HTMLElement ;
433- const key = that . getAttribute ( 'key' ) ;
434- if ( key ) {
435- const targetHtml = i18t ( key ) ;
436- ( that . innerHTML as string | TrustedHTML ) = defaultTrustedTypePolicy
437- ? defaultTrustedTypePolicy . createHTML ( targetHtml )
438- : targetHtml ;
439- }
440- } ;
441424 customElements . define (
442425 'pear-trans' ,
443- PearTrans as unknown as CustomElementConstructor ,
426+ class extends HTMLElement {
427+ connectedCallback ( ) {
428+ const key = this . getAttribute ( 'key' ) ;
429+ if ( key ) {
430+ const targetHtml = i18t ( key ) ;
431+ ( this . innerHTML as string | TrustedHTML ) = defaultTrustedTypePolicy
432+ ? defaultTrustedTypePolicy . createHTML ( targetHtml )
433+ : targetHtml ;
434+ }
435+ }
436+ } ,
444437 ) ;
445438} ;
446439
You can’t perform that action at this time.
0 commit comments