Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The count message always exists (since 7b534bf). This PR makes the markup for it required, instead of giving the option to add it with JS since the user needs to be informed of the limit in the number of characters they can type in even if JS doesn’t run. The count message DOM element is now defined at the top of the module with the other required DOM elements. We check whether the textarea is present before trying to its id to find the count message - the check prevents a DOM search error for `$textarea.id` if the script is run without component markup being present present on the page. Alternatively we could define the count message in `init()` after doing a check for textarea which would require another check for it and wouldn’t make it as clear that it’s required as when placed at the top of module. ``` CharacterCount.prototype.init = function () { var $module = this.$module var $textarea = this.$textarea if (!$textarea) { return } this.$countMessage = $module.querySelector('[id=' + this.$textarea.id + '-info]') if (!$countMessage) { return } ```
- Loading branch information