Title: Safe navigation does not guard array access · Issue #13254 · angular/angular · GitHub
Open Graph Title: Safe navigation does not guard array access · Issue #13254 · angular/angular
X Title: Safe navigation does not guard array access · Issue #13254 · angular/angular
Description: I'm submitting a ... (check one with "x") [ x ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/...
Open Graph Description: I'm submitting a ... (check one with "x") [ x ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support reque...
X Description: I'm submitting a ... (check one with "x") [ x ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not ...
Opengraph URL: https://github.com/angular/angular/issues/13254
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Safe navigation does not guard array access","articleBody":"\u003c!--\r\nIF YOU DON'T FILL OUT THE FOLLOWING INFORMATION WE MIGHT CLOSE YOUR ISSUE WITHOUT INVESTIGATING\r\n-->\r\n\r\n**I'm submitting a ...** (check one with \"x\")\r\n```\r\n[ x ] bug report => search github for a similar issue or PR before submitting\r\n[ ] feature request\r\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n```\r\n\r\n**Current behavior**\r\n\u003c!-- Describe how the bug manifests. -->\r\nUsing an array index after a safe navigation, e.g. `{{click?.pixel[0]}}`, crashes with a\r\n`Cannot read property '0' of null` when the guarded variable is null/undefined.\r\n\r\n**Expected behavior**\r\n\u003c!-- Describe what the behavior would be without the bug. -->\r\nThe safe operator should short-circuit the entire expression after the first null value, as it does when using property access, e.g. `{{click?.pixel.something}}`\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n\u003c!--\r\nIf the current behavior is a bug or you can illustrate your feature request better with an example, \r\nplease provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n-->\r\nhttps://plnkr.co/edit/lI5KozoN5xdvX1Gr0aVK\r\n\r\n**What is the motivation / use case for changing the behavior?**\r\n\u003c!-- Describe the motivation or the concrete use case -->\r\nThe current behavior is inconsistent with the expected use of the safe navigation. (Short-circuiting is discussed in #9850)\r\n\r\n**Please tell us about your environment:**\r\n\u003c!-- Operating system, IDE, package manager, HTTP server, ... -->\r\nN/A\r\n\r\n* **Angular version:** 2.0.X\r\n\u003c!-- Check whether this is still an issue in the most recent Angular version -->\r\n2.2.4\r\n\r\n* **Browser:** [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]\r\n\u003c!-- All browsers where this could be reproduced -->\r\nChrome 54.0.2840.99/Firefox 50.0.2.\r\n\r\n* **Language:** [all | TypeScript X.X | ES6/7 | ES5]\r\nTypeScript 2.0.10\r\n\r\n* **Node (for AoT issues):** `node --version` = \r\n","author":{"url":"https://github.com/wulfsberg","@type":"Person","name":"wulfsberg"},"datePublished":"2016-12-05T21:25:53Z","url":"https://github.com/angular/angular/issues/13254"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:348a0a94-00fe-cba2-b42a-fee78acec3a5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 819E:27D3AD:171B817:1D55490:6B0137E2 |
| html-safe-nonce | 50733a3833e0313584e09085cad8e5ec77f115d73cdd75f6b34c3b5747458a0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTlFOjI3RDNBRDoxNzFCODE3OjFENTU0OTA6NkIwMTM3RTIiLCJ2aXNpdG9yX2lkIjoiNzY0NzE0NDUwMTU4NDE0ODQ1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0253a2a77c0e1d3be34105322fee17dd3937cae9f06232031309f09e7ba1f160 |
| hovercard-subject-tag | issue:193614412 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/13254/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd8eb61e16c948428a9d9c0e0a01f9713cd24bde89b9f79ce7c7924ac1b19412/angular/angular/issues/13254 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd8eb61e16c948428a9d9c0e0a01f9713cd24bde89b9f79ce7c7924ac1b19412/angular/angular/issues/13254 |
| og:image:alt | I'm submitting a ... (check one with "x") [ x ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support reque... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wulfsberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width