Skip to content

Commit

Permalink
Don't allow openPopup if allowLinks=false, see phetsims/joist#830, ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Aug 11, 2022
1 parent 9be2a4f commit b53bad0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/openPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ import phetCore from './phetCore.js';
* @param {string} url
*/
function openPopup( url ) {
const popupWindow = window.open( url, '_blank' ); // open in a new window/tab

// We can't guarantee the presence of a window object, since if it isn't opened then it will return null.
// See https://github.com/phetsims/phet-ios-app/issues/508#issuecomment-520891177 and documentation at
// https://developer.mozilla.org/en-US/docs/Web/API/Window/open.
popupWindow && popupWindow.focus();
// Don't allow openPopup IF we have query parameters AND allowLinks is false,
// see https://github.com/phetsims/joist/issues/830
if ( !( window?.phet?.chipper?.queryParameters ) || ( window?.phet?.chipper?.queryParameters?.allowLinks ) ) {
const popupWindow = window.open( url, '_blank' ); // open in a new window/tab

// We can't guarantee the presence of a window object, since if it isn't opened then it will return null.
// See https://github.com/phetsims/phet-ios-app/issues/508#issuecomment-520891177 and documentation at
// https://developer.mozilla.org/en-US/docs/Web/API/Window/open.
popupWindow && popupWindow.focus();
}
}

phetCore.register( 'openPopup', openPopup );
Expand Down

0 comments on commit b53bad0

Please sign in to comment.