diff -u b/core/misc/message.js b/core/misc/message.js --- b/core/misc/message.js +++ b/core/misc/message.js @@ -16,10 +16,14 @@ */ /** - * woot + * Constructs a new instance of the Drupal.message object. * - * @param {HTMLElement?} messageWrapper - * The zone where to add messages. + * This provides a uniform interface for adding and removing messages to a + * specific location on the page. + * + * @param {HTMLElement} messageWrapper + * The zone where to add messages. If no element is supplied, the default + * selector is used. * * @return {Drupal.message~messageDefinition} * Object to add and remove messages. @@ -31,12 +35,12 @@ if (!messageWrapper) { messageWrapper = document.querySelector(defaultMessageWrapperSelector); if (!messageWrapper) { - throw new Error(Drupal.t('There is no @element on the page.', {'%element': defaultMessageWrapperSelector})); + throw new Error(Drupal.t('There is no @element on the page.', {'@element': defaultMessageWrapperSelector})); } } /** - * Displays a message on the page. + * Sequentially adds a message to the defined location in the page. * * @name Drupal.message~messageDefinition.add * @@ -84,7 +88,7 @@ throw new Error(Drupal.t('Object.message() expect a message to remove.')); } - var removeSelectors = (messages instanceof Array ? messages : [messages]) + var removeSelectors = (Array.isArray(messages) ? messages : [messages]) .map(function (messageIndex) { return '[data-drupal-message="' + messageIndex + '"]'; }); @@ -99,7 +103,6 @@ } return { - element: messageWrapper, add: messageAdd, remove: messageRemove };