Skip to content

Fix getting attribute from null element error in javascript

What does this MR do and why?

In https://gitlab.com/gitlab-org/gitlab/-/blob/58decbc3ff1c607dafc6438e9cfee1ccb1da426a/ee/app/assets/javascripts/password/password_validator.js#L16,

  • In EE Premium and EE Ultimate, when ::License.feature_available?(:password_complexity) is true, everything will OK.
  • In EE Starter, when ::License.feature_available?(:password_complexity) is false, el will be null , frontend will throw an Uncaught TypeError: Cannot read properties of null (reading 'dataset') error in browser console, but it will not affect page features because new PasswordValidator() is the last line in pages using it. This MR is to fix this error.

Screenshots or screen recordings

when ::License.feature_available?(:password_complexity) is false

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

/cc @daveliu @JeremyWuuuuu @orozot

Edited by Kun Qian

Merge request reports

Loading