Prefer to replace some of obj && obj.prop with optional chaining possibly

Created on 9 December 2024, 13 days ago

Problem/Motivation

This issue is similar to 📌 Prefer to replace some of typeof obj !== 'undefined' with optional chaining possibly Active .
Some of JavaScript checks object existence and checks property existence of this object with obj && obj.prop.
For example, checks settings object and its property exsitence with below code in the /core/modules/views/js/ajax_view.js.

if (settings && settings.views && settings.views.ajaxViews) {

If uses optional chaining expression, this code can makes code more shorter like below.

if (settings?.views?.ajaxViews)

Proposed resolution

Use optional chaining.

Remaining tasks

TBD

User interface changes

No.

API changes

No.

Data model changes

No.

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

javascript

Created by

🇯🇵Japan tom konda Kanagawa, Japan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024