Skip to content

Commit

Permalink
Fix ampproject#11549 to remove ugly ternary (ampproject#11630)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco authored and neko-fire committed Nov 17, 2017
1 parent 5bc1ec1 commit 41b4d16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions extensions/amp-story/0.1/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ export class AmpStory extends AMP.BaseElement {
return this.loadJsonFromAttribute_(BOOKEND_CONFIG_ATTRIBUTE_NAME)
.then(response => response && {
shareProviders: response['share-providers'],
relatedArticles: response['related-articles'] ?
relatedArticlesFromJson(response['related-articles']) : [],
relatedArticles:
relatedArticlesFromJson(response['related-articles']),
})
.catch(e => {
user().error(TAG, 'Error fetching bookend configuration', e.message);
Expand Down
8 changes: 4 additions & 4 deletions extensions/amp-story/0.1/related-articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ function buildArticleFromJson_(articleJson) {


/**
* @param {!JsonObject} articleSetsResponse
* @param {!JsonObject=} opt_articleSetsResponse
* @return {!Array<!RelatedArticleSetDef>}
*/
export function relatedArticlesFromJson(articleSetsResponse) {
export function relatedArticlesFromJson(opt_articleSetsResponse) {
return /** @type {!Array<!RelatedArticleSetDef>} */ (
Object.keys(articleSetsResponse).map(headingKey => {
Object.keys(opt_articleSetsResponse || {}).map(headingKey => {
const articleSet = {
articles:
articleSetsResponse[headingKey]
opt_articleSetsResponse[headingKey]
.map(buildArticleFromJson_)
.filter(a => !!a),
};
Expand Down

0 comments on commit 41b4d16

Please sign in to comment.