Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295606

Mark {Drupal~behaviorDetach} as optional in jsdoc.

$
0
0

Problem/Motivation

When adding to Drupal.behaviors without a "detach" method, inspection tools that are aware of jsdoc will complain:

Steps to reproduce

  Drupal.behaviors.myBehavior = {
    attach: function () {},
  };
Assigned expression type {attach: Drupal.behaviors.myBehavior.attach} is not assignable to type {detach: Drupal~behaviorDetach, attach: Drupal~behaviorAttach}

Proposed resolution

In all places where we define this property, replace like this:

    * @type {Drupal~behavior}
    *
    * @prop {Drupal~behaviorAttach} attach
    *   Attaches the autocomplete behaviors.
-   * @prop {Drupal~behaviorDetach} detach
+   * @prop {Drupal~behaviorDetach} [detach]
    *   Detaches the autocomplete behaviors.

See https://jsdoc.app/tags-property.html, look for "optional property".

Remaining tasks

User interface changes

API changes

none

Data model changes

none

Release notes snippet


Viewing all articles
Browse latest Browse all 295606


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>