@@ -107,38 +107,36 @@ function lossEnricher(text, options) {
107107 * @returns {Promise<void> }
108108 */
109109async function onRender ( element ) {
110- const document = InlineHelper . resolveDocument ( element ) ;
110+ const renderContext = await InlineHelper . getRenderContext ( element ) ;
111111 const target = element . firstElementChild ;
112- const sourceInfo = InlineHelper . determineSource ( document , target ) ;
113- const dataset = target . dataset ;
114- const type = dataset . type ;
115- const uncapped = dataset . uncapped === 'true' ;
112+ const type = renderContext . dataset . type ;
113+ const uncapped = renderContext . dataset . uncapped === 'true' ;
116114
117115 element . addEventListener ( 'click' , async function ( ) {
118116 const targets = await targetHandler ( ) ;
119117 if ( targets . length > 0 ) {
120- let context = ExpressionContext . fromSourceInfo ( sourceInfo , targets ) ;
121- let check = document . getFlag ( SYSTEM , Flags . ChatMessage . CheckV2 ) ;
118+ let context = ExpressionContext . fromSourceInfo ( renderContext . sourceInfo , targets ) ;
119+ let check = renderContext . document . getFlag ( SYSTEM , Flags . ChatMessage . CheckV2 ) ;
122120 if ( check ) {
123121 context = context . withCheck ( check ) ;
124122 }
125- const amount = await Expressions . evaluateAsync ( dataset . amount , context ) ;
123+ const amount = await Expressions . evaluateAsync ( renderContext . dataset . amount , context ) ;
126124
127125 if ( target . classList . contains ( classInlineRecovery ) ) {
128- await applyRecovery ( sourceInfo , targets , type , amount , uncapped ) ;
126+ await applyRecovery ( renderContext . sourceInfo , targets , type , amount , uncapped ) ;
129127 } else if ( target . classList . contains ( classInlineLoss ) ) {
130- await applyLoss ( sourceInfo , targets , type , amount ) ;
128+ await applyLoss ( renderContext . sourceInfo , targets , type , amount ) ;
131129 }
132130 }
133131 } ) ;
134132
135133 element . addEventListener ( 'dragstart' , function ( event ) {
136134 const data = {
137135 type : target . classList . contains ( classInlineRecovery ) ? INLINE_RECOVERY : INLINE_LOSS ,
138- sourceInfo,
139- recoveryType : dataset . type ,
140- amount : dataset . amount ,
141- uncapped : dataset . uncapped === 'true' ,
136+ sourceInfo : renderContext . sourceInfo ,
137+ recoveryType : renderContext . dataset . type ,
138+ amount : renderContext . dataset . amount ,
139+ uncapped : renderContext . dataset . uncapped === 'true' ,
142140 } ;
143141
144142 event . dataTransfer . setData ( 'text/plain' , JSON . stringify ( data ) ) ;
0 commit comments