Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@guardian/cdk": "61.4.0",
"@guardian/content-api-models": "31.0.0",
"@guardian/content-atom-model": "6.1.0",
"@guardian/eslint-config-typescript": "10.0.1",
"@guardian/eslint-config-typescript": "11.0.0",
"@guardian/libs": "22.0.0",
"@guardian/renditions": "0.2.0",
"@guardian/source": "9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@guardian/cdk": "61.4.0",
"@guardian/commercial-core": "28.0.0",
"@guardian/core-web-vitals": "7.0.0",
"@guardian/eslint-config-typescript": "10.0.1",
"@guardian/eslint-config-typescript": "11.0.0",
"@guardian/identity-auth": "6.0.1",
"@guardian/identity-auth-frontend": "8.1.0",
"@guardian/libs": "26.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ export const InteractiveBlockComponent = ({
const { darkModeAvailable, renderingTarget } = useConfig();

// Define some one-time flags
const isDatawrapperGraphic =
url && url.includes('interactive.guim.co.uk/datawrapper')
? true
: false;
const isDatawrapperGraphic = url?.includes(
'interactive.guim.co.uk/datawrapper',
)
? true
: false;
Comment on lines +331 to +335
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the result of the expression should be the same. Technically the behaviour changes slightly in the empty string ('') case. The previous behaviour:

  1. '' is falsy
  2. '' && ''.includes(...) evaluates to '', skipping the includes
  3. That's coerced to false
  4. The ternary condition is false, so it returns false

Now:

  1. '' is neither undefined or null
  2. Optional chaining doesn't short circuit, so includes is evaluated
  3. '' doesn't include the string being tested for, so the result is false
  4. The ternary condition is false, so it returns false

As in practice the empty string will not include either the string being tested here, or the one in the scriptUrlIsBoot expression below, there should be no change in functionality.

Does that sound correct @RikRootsGuardian ? I believe it was your change that introduced these expressions originally?


const isUploaderEmbedPath =
url &&
Expand All @@ -341,13 +342,11 @@ export const InteractiveBlockComponent = ({
? true
: false;

const scriptUrlIsBoot =
scriptUrl &&
scriptUrl.includes(
'interactive.guim.co.uk/embed/iframe-wrapper/0.1/boot.js',
)
? true
: false;
const scriptUrlIsBoot = scriptUrl?.includes(
'interactive.guim.co.uk/embed/iframe-wrapper/0.1/boot.js',
)
? true
: false;

useOnce(() => {
// We've brought the behavior from boot.js into this file to avoid loading 2 extra scripts
Expand Down
Loading
Loading