Skip to content

Commit

Permalink
Suppress undefined errors in both directions, see phetsims/phet-io-wr…
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 27, 2021
1 parent 22fede3 commit 338f4d2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions js/phet-io/phetioCompareAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
*
* NOTE: Named with an underscore to avoid automatically defining `window.phetioCompareAPIs` as a global
*
* @param {API_1_0} referenceAPI - the "ground truth" or reference API
* @param {API} referenceAPI - the "ground truth" or reference API
* @param {API} proposedAPI - the proposed API for comparison with referenceAPI
* @param _ - lodash, so this can be used from different contexts.
* @param {function|undefined} assert - so this can be used from different contexts
Expand All @@ -140,13 +140,15 @@
*/
const _phetioCompareAPIs = ( referenceAPI, proposedAPI, _, assert, options ) => {

assert && assert( !isOldAPIVersion( referenceAPI ) && referenceAPI.version.major >= 1, 'referenceAPI must be versioned >= 1.0' );

// If the proposed version predates 1.0, then bring it forward to the structured tree with metadata under `_metadata`.
if ( isOldAPIVersion( proposedAPI ) ) {
proposedAPI = toStructuredTree( proposedAPI, _ );
}

if ( isOldAPIVersion( referenceAPI ) ) {
referenceAPI = toStructuredTree( referenceAPI, _ );
}

options = _.merge( {
compareDesignedAPIChanges: true,
compareBreakingAPIChanges: true
Expand Down Expand Up @@ -201,10 +203,17 @@

// if proposed API is older (no version specified), ignore phetioArchetypePhetioID changed from null to undefined
// because it used to be sparse, and in version 1.0 it became a default.
const ignore = isOldAPIVersion( proposedAPI ) &&
metadataKey === 'phetioArchetypePhetioID' &&
referenceValue === null &&
proposedValue === undefined;
const ignoreBrokenProposed = isOldAPIVersion( proposedAPI ) &&
metadataKey === 'phetioArchetypePhetioID' &&
referenceValue === null &&
proposedValue === undefined;

const ignoreBrokenReference = isOldAPIVersion( referenceAPI ) &&
metadataKey === 'phetioArchetypePhetioID' &&
proposedValue === null &&
referenceValue === undefined;

const ignore = ignoreBrokenProposed || ignoreBrokenReference;

if ( !ignore ) {

Expand Down

0 comments on commit 338f4d2

Please sign in to comment.