angular-ui / ui-mask

Mask on an input field so the user can only type pre-determined pattern
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
MIT License
391 stars 257 forks source link

Incorrect isDefined check for placeholder causes errors when used with Angular Material #181

Open mgol opened 8 years ago

mgol commented 8 years ago

See: https://codepen.io/mgol/pen/GjKqka

The main cause of the bug is the line at https://github.com/angular-ui/ui-mask/blob/1.8.7/src/mask.js#L341:

if (angular.isDefined(placeholder) && placeholder[i]) {

angular.isDefined(null) is true and Angular Material makes placeholder be null here so errors appear as you can see in the codepen.

Changing angular.isDefined(null) to angular.isString(placeholder) should help.