diff --git a/resources/dist/index.js b/resources/dist/index.js index e89cd88ac..f6f8597ad 100644 Binary files a/resources/dist/index.js and b/resources/dist/index.js differ diff --git a/resources/dist/index.js.map.json b/resources/dist/index.js.map.json index 62636fedd..f3283f34d 100644 Binary files a/resources/dist/index.js.map.json and b/resources/dist/index.js.map.json differ diff --git a/src/ui/renderer.js b/src/ui/renderer.js index 0bc01bcc8..e8f4fac2d 100644 --- a/src/ui/renderer.js +++ b/src/ui/renderer.js @@ -244,19 +244,8 @@ function createDisambiguationPreview( model ) { * @return {ext.popups.Preview} */ function createReferencePreview( model ) { - const $el = $( - $.parseHTML( renderReferencePreview( model ) ) - ); - - // Make sure to not destroy existing targets, if any - $el.find( '.mwe-popups-extract a[href]:not([target])' ).each( ( i, a ) => { - a.target = '_blank'; - // Don't let the external site access and possibly manipulate window.opener.location - a.rel = `${ a.rel ? `${ a.rel } ` : '' }noopener`; - } ); - return { - el: $el, + el: renderReferencePreview( model ), hasThumbnail: false, isTall: false }; diff --git a/src/ui/templates/referencePreview/referencePreview.js b/src/ui/templates/referencePreview/referencePreview.js index bec39dff8..5903a8308 100644 --- a/src/ui/templates/referencePreview/referencePreview.js +++ b/src/ui/templates/referencePreview/referencePreview.js @@ -9,7 +9,7 @@ const mw = mediaWiki; /** * @param {ext.popups.PreviewModel} model - * @return {string} HTML string. + * @return {jQuery} */ export function renderReferencePreview( model @@ -18,7 +18,7 @@ export function renderReferencePreview( url = escapeHTML( model.url ), linkMsg = escapeHTML( mw.msg( 'popups-refpreview-jump-to-reference' ) ); - return renderPopup( model.type, + const $el = $( $.parseHTML( renderPopup( model.type, ` @@ -31,5 +31,14 @@ export function renderReferencePreview( ${ linkMsg } ` - ); + ) ) ); + + // Make sure to not destroy existing targets, if any + $el.find( '.mwe-popups-extract a[href]:not([target])' ).each( ( i, a ) => { + a.target = '_blank'; + // Don't let the external site access and possibly manipulate window.opener.location + a.rel = `${ a.rel ? `${ a.rel } ` : '' }noopener`; + } ); + + return $el; }